@@ -60,27 +60,15 @@ public string GetValue(Property property, ICollection<ArtifactDependency> depend
60
60
if ( innerContent == null )
61
61
return null ;
62
62
63
- var allContentTypes = innerContent . Select ( x => x . IcContentTypeAlias )
64
- . Distinct ( )
65
- . ToDictionary ( a => a , a => _contentTypeService . GetContentType ( a ) ) ;
66
-
67
- //Ensure all of these content types are found
68
- if ( allContentTypes . Values . Any ( contentType => contentType == null ) )
69
- {
70
- throw new InvalidOperationException ( $ "Could not resolve these content types for the Inner Content property: { string . Join ( "," , allContentTypes . Where ( x => x . Value == null ) . Select ( x => x . Key ) ) } ") ;
71
- }
72
-
73
- //Ensure that these content types have dependencies added
74
- foreach ( var contentType in allContentTypes . Values )
75
- {
76
- dependencies . Add ( new ArtifactDependency ( contentType . GetUdi ( ) , false , ArtifactDependencyMode . Match ) ) ;
77
- }
78
-
79
- foreach ( var row in innerContent )
63
+ foreach ( var innerContentItem in innerContent )
80
64
{
81
- var contentType = allContentTypes [ row . IcContentTypeAlias ] ;
65
+ var contentType = _contentTypeService . GetContentType ( innerContentItem . IcContentTypeGuid ) ;
66
+ if ( contentType == null )
67
+ contentType = _contentTypeService . GetContentType ( innerContentItem . IcContentTypeAlias ) ;
68
+ if ( contentType == null )
69
+ throw new InvalidOperationException ( $ "Could not resolve these content types for the Inner Content property with key: { innerContentItem . Key } , and name: { innerContentItem . Name } ") ;
82
70
83
- foreach ( var key in row . PropertyValues . Keys . ToArray ( ) )
71
+ foreach ( var key in innerContentItem . PropertyValues . Keys . ToArray ( ) )
84
72
{
85
73
var propertyType = contentType . CompositionPropertyTypes . FirstOrDefault ( x => x . Alias == key ) ;
86
74
@@ -95,7 +83,7 @@ public string GetValue(Property property, ICollection<ArtifactDependency> depend
95
83
96
84
// this should be enough for all other value connectors to work with
97
85
// as all they should need is the value, and the property type infos
98
- var mockProperty = new Property ( propertyType , row . PropertyValues [ key ] ) ;
86
+ var mockProperty = new Property ( propertyType , innerContentItem . PropertyValues [ key ] ) ;
99
87
100
88
object parsedValue = propValueConnector . GetValue ( mockProperty , dependencies ) ;
101
89
@@ -111,7 +99,7 @@ public string GetValue(Property property, ICollection<ArtifactDependency> depend
111
99
parsedValue = parsedValue . ToString ( ) ;
112
100
}
113
101
114
- row . PropertyValues [ key ] = parsedValue ;
102
+ innerContentItem . PropertyValues [ key ] = parsedValue ;
115
103
}
116
104
}
117
105
@@ -147,21 +135,16 @@ public void SetValue(IContentBase content, string alias, string value)
147
135
if ( innerContent == null )
148
136
return ;
149
137
150
- var allContentTypes = innerContent . Select ( x => x . IcContentTypeAlias )
151
- . Distinct ( )
152
- . ToDictionary ( a => a , a => _contentTypeService . GetContentType ( a ) ) ;
153
-
154
- //Ensure all of these content types are found
155
- if ( allContentTypes . Values . Any ( contentType => contentType == null ) )
138
+ foreach ( var innerContentItem in innerContent )
156
139
{
157
- throw new InvalidOperationException ( $ "Could not resolve these content types for the Inner Content property: { string . Join ( "," , allContentTypes . Where ( x => x . Value == null ) . Select ( x => x . Key ) ) } ") ;
158
- }
140
+ var contentType = _contentTypeService . GetContentType ( innerContentItem . IcContentTypeGuid ) ;
141
+ if ( contentType == null )
142
+ contentType = _contentTypeService . GetContentType ( innerContentItem . IcContentTypeAlias ) ;
143
+ if ( contentType == null )
144
+ throw new InvalidOperationException ( $ "Could not resolve these content types for the Inner Content property with key: { innerContentItem . Key } , and name: { innerContentItem . Name } ") ;
159
145
160
- var mocks = new Dictionary < IContentType , IContent > ( ) ;
161
146
162
- foreach ( var row in innerContent )
163
- {
164
- var contentType = allContentTypes [ row . IcContentTypeAlias ] ;
147
+ var mocks = new Dictionary < IContentType , IContent > ( ) ;
165
148
166
149
// note
167
150
// the way we do it here, doing content.SetValue() several time on the same content, reduces
@@ -176,7 +159,7 @@ public void SetValue(IContentBase content, string alias, string value)
176
159
if ( ! mocks . TryGetValue ( contentType , out mockContent ) )
177
160
mockContent = mocks [ contentType ] = new Content ( "IC_" + Guid . NewGuid ( ) , - 1 , contentType ) ;
178
161
179
- foreach ( var key in row . PropertyValues . Keys . ToArray ( ) )
162
+ foreach ( var key in innerContentItem . PropertyValues . Keys . ToArray ( ) )
180
163
{
181
164
var propertyType = contentType . CompositionPropertyTypes . FirstOrDefault ( x => x . Alias == key ) ;
182
165
@@ -189,7 +172,7 @@ public void SetValue(IContentBase content, string alias, string value)
189
172
// throws if not found - no need for a null check
190
173
var propValueConnector = ValueConnectors . Get ( propertyType ) ;
191
174
192
- var rowValue = row . PropertyValues [ key ] ;
175
+ var rowValue = innerContentItem . PropertyValues [ key ] ;
193
176
194
177
if ( rowValue != null )
195
178
{
@@ -198,7 +181,7 @@ public void SetValue(IContentBase content, string alias, string value)
198
181
// integers needs to be converted into strings
199
182
if ( convertedValue is int )
200
183
{
201
- row . PropertyValues [ key ] = convertedValue . ToString ( ) ;
184
+ innerContentItem . PropertyValues [ key ] = convertedValue . ToString ( ) ;
202
185
}
203
186
else
204
187
{
@@ -207,17 +190,17 @@ public void SetValue(IContentBase content, string alias, string value)
207
190
var jtokenValue = convertedValue . ToString ( ) . DetectIsJson ( ) ? JToken . Parse ( convertedValue . ToString ( ) ) : null ;
208
191
if ( jtokenValue != null )
209
192
{
210
- row . PropertyValues [ key ] = jtokenValue ;
193
+ innerContentItem . PropertyValues [ key ] = jtokenValue ;
211
194
}
212
195
else
213
196
{
214
- row . PropertyValues [ key ] = convertedValue ;
197
+ innerContentItem . PropertyValues [ key ] = convertedValue ;
215
198
}
216
199
}
217
200
}
218
201
else
219
202
{
220
- row . PropertyValues [ key ] = rowValue ;
203
+ innerContentItem . PropertyValues [ key ] = rowValue ;
221
204
}
222
205
}
223
206
}
@@ -250,6 +233,8 @@ public class InnerContentValue
250
233
public string Icon { get ; set ; }
251
234
[ JsonProperty ( "icContentTypeAlias" ) ]
252
235
public string IcContentTypeAlias { get ; set ; }
236
+ [ JsonProperty ( "icContentTypeGuid" ) ]
237
+ public Guid IcContentTypeGuid { get ; set ; }
253
238
254
239
/// <summary>
255
240
/// The remaining properties will be serialized to a dictionary
0 commit comments