@@ -79,38 +79,41 @@ public string GetValue(Property property, ICollection<ArtifactDependency> depend
79
79
dependencies . Add ( new ArtifactDependency ( contentTypeUdi , false , ArtifactDependencyMode . Match ) ) ;
80
80
}
81
81
82
- foreach ( var key in innerContentItem . PropertyValues . Keys . ToArray ( ) )
82
+ if ( innerContentItem . PropertyValues != null )
83
83
{
84
- var propertyType = contentType . CompositionPropertyTypes . FirstOrDefault ( x => x . Alias == key ) ;
85
-
86
- if ( propertyType == null )
84
+ foreach ( var key in innerContentItem . PropertyValues . Keys . ToArray ( ) )
87
85
{
88
- LogHelper . Debug < InnerContentConnector > ( $ "No Property Type found with alias { key } on Content Type { contentType . Alias } ") ;
89
- continue ;
90
- }
86
+ var propertyType = contentType . CompositionPropertyTypes . FirstOrDefault ( x => x . Alias == key ) ;
91
87
92
- // throws if not found - no need for a null check
93
- var propValueConnector = ValueConnectors . Get ( propertyType ) ;
88
+ if ( propertyType == null )
89
+ {
90
+ LogHelper . Debug < InnerContentConnector > ( $ "No Property Type found with alias { key } on Content Type { contentType . Alias } ") ;
91
+ continue ;
92
+ }
94
93
95
- // this should be enough for all other value connectors to work with
96
- // as all they should need is the value, and the property type infos
97
- var mockProperty = new Property ( propertyType , innerContentItem . PropertyValues [ key ] ) ;
94
+ // throws if not found - no need for a null check
95
+ var propValueConnector = ValueConnectors . Get ( propertyType ) ;
98
96
99
- object parsedValue = propValueConnector . GetValue ( mockProperty , dependencies ) ;
97
+ // this should be enough for all other value connectors to work with
98
+ // as all they should need is the value, and the property type infos
99
+ var mockProperty = new Property ( propertyType , innerContentItem . PropertyValues [ key ] ) ;
100
100
101
- // test if the value is a json object (thus could be a nested complex editor)
102
- // if that's the case we'll need to add it as a json object instead of string to avoid it being escaped
103
- var jtokenValue = parsedValue != null && parsedValue . ToString ( ) . DetectIsJson ( ) ? JToken . Parse ( parsedValue . ToString ( ) ) : null ;
104
- if ( jtokenValue != null )
105
- {
106
- parsedValue = jtokenValue ;
107
- }
108
- else if ( parsedValue != null )
109
- {
110
- parsedValue = parsedValue . ToString ( ) ;
111
- }
101
+ object parsedValue = propValueConnector . GetValue ( mockProperty , dependencies ) ;
112
102
113
- innerContentItem . PropertyValues [ key ] = parsedValue ;
103
+ // test if the value is a json object (thus could be a nested complex editor)
104
+ // if that's the case we'll need to add it as a json object instead of string to avoid it being escaped
105
+ var jtokenValue = parsedValue != null && parsedValue . ToString ( ) . DetectIsJson ( ) ? JToken . Parse ( parsedValue . ToString ( ) ) : null ;
106
+ if ( jtokenValue != null )
107
+ {
108
+ parsedValue = jtokenValue ;
109
+ }
110
+ else if ( parsedValue != null )
111
+ {
112
+ parsedValue = parsedValue . ToString ( ) ;
113
+ }
114
+
115
+ innerContentItem . PropertyValues [ key ] = parsedValue ;
116
+ }
114
117
}
115
118
}
116
119
@@ -171,48 +174,51 @@ public void SetValue(IContentBase content, string alias, string value)
171
174
if ( ! mocks . TryGetValue ( contentType , out mockContent ) )
172
175
mockContent = mocks [ contentType ] = new Content ( "IC_" + Guid . NewGuid ( ) , - 1 , contentType ) ;
173
176
174
- foreach ( var key in innerContentItem . PropertyValues . Keys . ToArray ( ) )
177
+ if ( innerContentItem . PropertyValues != null )
175
178
{
176
- var propertyType = contentType . CompositionPropertyTypes . FirstOrDefault ( x => x . Alias == key ) ;
177
-
178
- if ( propertyType == null )
179
+ foreach ( var key in innerContentItem . PropertyValues . Keys . ToArray ( ) )
179
180
{
180
- LogHelper . Debug < InnerContentConnector > ( $ "No Property Type found with alias { key } on Content Type { contentType . Alias } ") ;
181
- continue ;
182
- }
183
-
184
- // throws if not found - no need for a null check
185
- var propValueConnector = ValueConnectors . Get ( propertyType ) ;
186
-
187
- var rowValue = innerContentItem . PropertyValues [ key ] ;
181
+ var propertyType = contentType . CompositionPropertyTypes . FirstOrDefault ( x => x . Alias == key ) ;
188
182
189
- if ( rowValue != null )
190
- {
191
- propValueConnector . SetValue ( mockContent , propertyType . Alias , rowValue . ToString ( ) ) ;
192
- var convertedValue = mockContent . GetValue ( propertyType . Alias ) ;
193
- // integers needs to be converted into strings
194
- if ( convertedValue is int )
183
+ if ( propertyType == null )
195
184
{
196
- innerContentItem . PropertyValues [ key ] = convertedValue . ToString ( ) ;
185
+ LogHelper . Debug < InnerContentConnector > ( $ "No Property Type found with alias { key } on Content Type { contentType . Alias } ") ;
186
+ continue ;
197
187
}
198
- else
188
+
189
+ // throws if not found - no need for a null check
190
+ var propValueConnector = ValueConnectors . Get ( propertyType ) ;
191
+
192
+ var rowValue = innerContentItem . PropertyValues [ key ] ;
193
+
194
+ if ( rowValue != null )
199
195
{
200
- // test if the value is a json object (thus could be a nested complex editor)
201
- // if that's the case we'll need to add it as a json object instead of string to avoid it being escaped
202
- var jtokenValue = convertedValue . ToString ( ) . DetectIsJson ( ) ? JToken . Parse ( convertedValue . ToString ( ) ) : null ;
203
- if ( jtokenValue != null )
196
+ propValueConnector . SetValue ( mockContent , propertyType . Alias , rowValue . ToString ( ) ) ;
197
+ var convertedValue = mockContent . GetValue ( propertyType . Alias ) ;
198
+ // integers needs to be converted into strings
199
+ if ( convertedValue is int )
204
200
{
205
- innerContentItem . PropertyValues [ key ] = jtokenValue ;
201
+ innerContentItem . PropertyValues [ key ] = convertedValue . ToString ( ) ;
206
202
}
207
203
else
208
204
{
209
- innerContentItem . PropertyValues [ key ] = convertedValue ;
205
+ // test if the value is a json object (thus could be a nested complex editor)
206
+ // if that's the case we'll need to add it as a json object instead of string to avoid it being escaped
207
+ var jtokenValue = convertedValue . ToString ( ) . DetectIsJson ( ) ? JToken . Parse ( convertedValue . ToString ( ) ) : null ;
208
+ if ( jtokenValue != null )
209
+ {
210
+ innerContentItem . PropertyValues [ key ] = jtokenValue ;
211
+ }
212
+ else
213
+ {
214
+ innerContentItem . PropertyValues [ key ] = convertedValue ;
215
+ }
210
216
}
211
217
}
212
- }
213
- else
214
- {
215
- innerContentItem . PropertyValues [ key ] = rowValue ;
218
+ else
219
+ {
220
+ innerContentItem . PropertyValues [ key ] = rowValue ;
221
+ }
216
222
}
217
223
}
218
224
}
0 commit comments