chr
2026-04-05 fe750b791d5b517cc4e9bc8e99a9a75139a0cfba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Linq;
 
namespace OpenTap
{
    class ParameterizedIconAnnotation :IIconAnnotation, IEnabledAnnotation, ISettingReferenceIconAnnotation
    {
        public string IconName => IconNames.Parameterized;
        /// <summary> Parameterized properties are disabled is controlled by the parent parameter </summary>
        public bool IsEnabled => false;
 
        public Guid TestStepReference { get; set; }
 
        public string MemberName { get; set; }
    }
 
    class ParameterIconAnnotation : IInteractiveIconAnnotation
    {
        public string IconName => IconNames.EditParameter;
        public AnnotationCollection Action => annotation.Get<MenuAnnotation>().MenuItems
            .FirstOrDefault(x => x.Get<IconAnnotationAttribute>()?.IconName == IconName);
        public ParameterIconAnnotation(AnnotationCollection annotation) => this.annotation = annotation;
        
        readonly AnnotationCollection annotation;
    }
    
    class InputIconAnnotation : IIconAnnotation, IEnabledAnnotation, ISettingReferenceIconAnnotation
    {
        public string IconName => IconNames.Input;
        
        /// <summary> Inputs are disabled in the GUI and is controlled by the output parameter </summary>
        public bool IsEnabled => false;
 
        public Guid TestStepReference { get; set; }
 
        public string MemberName { get; set; }
    }
 
    class OutputAnnotation : IIconAnnotation
    {
        public string IconName => IconNames.Output;
    }
    
    class OutputAssignedAnnotation : IIconAnnotation, ISettingReferenceIconAnnotation
    {
        public string IconName => IconNames.OutputAssigned;
 
        public Guid TestStepReference { get; set; }
 
        public string MemberName { get; set; }
    }
 
    class IconAnnotationHelper
    {
        public static void AddParameter(AnnotationCollection annotation, IMemberData member, object source)
        {
            var stepModel = TestStepMenuModel.FromSource(member, annotation.Source);
            if (stepModel != null)
            {
                if (stepModel.IsParameterized)
                {
                    if (annotation.Source is ITestStepParent step)
                    {
                        (IParameterMemberData parameter, object parent) = ParameterizedMembersCache.GetParameterFor(step, member);   
                        annotation.Add(new ParameterizedIconAnnotation
                        {
                            TestStepReference = (parent as ITestStep)?.Id ?? Guid.Empty,
                            MemberName = parameter?.Name
                        });
                    }
                    else // this is the multiselect case (source is an array)
                    {
                        annotation.Add(new ParameterizedIconAnnotation());
                    }
                }
                
                if (stepModel.IsParameter)
                    annotation.Add(new ParameterIconAnnotation(annotation));
                if (stepModel.IsOutput)
                    annotation.Add(new OutputAnnotation());
                if (stepModel.IsAnyInputAssigned) // this is an assigned output. In case of multiselect, at least one of the selected step has this as an assigned output
                {
                    if (annotation.Source is ITestStepParent step)
                    {
                        var relation = InputOutputRelation.GetRelations(step).FirstOrDefault(r => r.OutputMember == member && r.OutputObject == source);
                        annotation.Add(new OutputAssignedAnnotation
                        {
                            TestStepReference = (relation.InputObject as ITestStep)?.Id ?? Guid.Empty,
                            MemberName = relation.InputMember.Name
                        });
                    }
                    else // this is the multiselect case (source is an array)
                    {
                        annotation.Add(new OutputAssignedAnnotation()); // In case of multiselect, don't populate the ISettingReferenceIconAnnotation part
 
                    }
                }
                if (stepModel.IsAnyOutputAssigned) // this is an input. In case of multiselect, at least one of the selected step has this as an input
                {
                    if (annotation.Source is ITestStepParent step)
                    {
                        var relation = InputOutputRelation.GetRelations(step).FirstOrDefault(r => r.InputMember == member && r.InputObject == source);
                        annotation.Add(new InputIconAnnotation
                        {
                            TestStepReference = (relation.OutputObject as ITestStep)?.Id ?? Guid.Empty,
                            MemberName = relation.OutputMember.Name
                        });
                    }
                    else // this is the multiselect case (source is an array)
                    {
                        annotation.Add(new InputIconAnnotation()); // In case of multiselect, don't populate the ISettingReferenceIconAnnotation part
                    }
                }
            }
        }
    }
}