@@ -6,13 +6,24 @@ This source code is licensed under the Apache License 2.0 (see LICENSE.txt).
6
6
7
7
This source code may use other Open Source software components (see LICENSE.txt).
8
8
*/
9
+ using System ;
9
10
using System . Collections . Generic ;
10
11
11
12
namespace Extensions
12
13
{
13
14
// TODO (Jui, 2022-12-21): I do not know, if to put the List<> extension here or in a separate file
14
15
public static class ExtendListOfEmbeddedDataSpecification
15
16
{
17
+ public static bool IsOneBlank ( this List < IEmbeddedDataSpecification > list )
18
+ {
19
+ return
20
+ list != null
21
+ && list . Count == 1
22
+ && list [ 0 ] ? . DataSpecification ? . IsOneBlank ( ) == true
23
+ && list [ 0 ] . DataSpecificationContent is DataSpecificationBlank ;
24
+ }
25
+
26
+
16
27
public static IEmbeddedDataSpecification FindFirstIEC61360Spec ( this List < IEmbeddedDataSpecification > list )
17
28
{
18
29
foreach ( var eds in list )
@@ -119,5 +130,73 @@ public static bool FixReferenceWrtContent(this IEmbeddedDataSpecification eds)
119
130
new List < IKey > { ExtendIDataSpecificationContent . GetKeyFor ( ctc ) } ) ;
120
131
return true ;
121
132
}
133
+
134
+ }
135
+
136
+ /// <summary>
137
+ /// This class is intended to provide a "blank" DataSpecificationContent
138
+ /// in order to satisfy the cardinality [1] of EmbeddedDataSpecification.
139
+ /// It has no specific semantics or sense. It is purely existing.
140
+ /// </summary>
141
+ public class DataSpecificationBlank : IDataSpecificationContent
142
+ {
143
+ /// <summary>
144
+ /// Iterate over all the class instances referenced from this instance
145
+ /// without further recursion.
146
+ /// </summary>
147
+ public IEnumerable < IClass > DescendOnce ( )
148
+ {
149
+ yield break ;
150
+ }
151
+
152
+ /// <summary>
153
+ /// Iterate recursively over all the class instances referenced from this instance.
154
+ /// </summary>
155
+ public IEnumerable < IClass > Descend ( )
156
+ {
157
+ yield break ;
158
+ }
159
+
160
+ /// <summary>
161
+ /// Accept the <paramref name="visitor" /> to visit this instance
162
+ /// for double dispatch.
163
+ /// </summary>
164
+ public void Accept ( Visitation . IVisitor visitor )
165
+ {
166
+ }
167
+
168
+ /// <summary>
169
+ /// Accept the visitor to visit this instance for double dispatch
170
+ /// with the <paramref name="context" />.
171
+ /// </summary>
172
+ public void Accept < TContext > (
173
+ Visitation . IVisitorWithContext < TContext > visitor ,
174
+ TContext context )
175
+ {
176
+ }
177
+
178
+ /// <summary>
179
+ /// Accept the <paramref name="transformer" /> to transform this instance
180
+ /// for double dispatch.
181
+ /// </summary>
182
+ public T Transform < T > ( Visitation . ITransformer < T > transformer )
183
+ {
184
+ return default ( T ) ;
185
+ }
186
+
187
+ /// <summary>
188
+ /// Accept the <paramref name="transformer" /> to visit this instance
189
+ /// for double dispatch with the <paramref name="context" />.
190
+ /// </summary>
191
+ public T Transform < TContext , T > (
192
+ Visitation . ITransformerWithContext < TContext , T > transformer ,
193
+ TContext context )
194
+ {
195
+ return default ( T ) ;
196
+ }
197
+
198
+ public DataSpecificationBlank ( )
199
+ {
200
+ }
122
201
}
123
202
}
0 commit comments