@@ -83,30 +83,34 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
83
83
{
84
84
var contentType = allContentTypes [ block . ContentTypeKey ] ;
85
85
86
- foreach ( var key in block . PropertyValues . Keys . ToArray ( ) )
86
+ if ( block . PropertyValues != null )
87
87
{
88
- var propType = contentType . CompositionPropertyTypes . FirstOrDefault ( x => x . Alias == key ) ;
89
-
90
- if ( propType == null )
88
+ foreach ( var key in block . PropertyValues . Keys . ToArray ( ) )
91
89
{
92
- _logger . Debug < BlockEditorValueConnector > ( "No property type found with alias {Key} on content type {ContentTypeAlias}." , key , contentType . Alias ) ;
93
- continue ;
94
- }
90
+ var propType = contentType . CompositionPropertyTypes . FirstOrDefault ( x => x . Alias == key ) ;
91
+
92
+ if ( propType == null )
93
+ {
94
+ _logger . Debug < BlockEditorValueConnector > ( "No property type found with alias {Key} on content type {ContentTypeAlias}." , key , contentType . Alias ) ;
95
+ continue ;
96
+ }
95
97
96
- // fetch the right value connector from the collection of connectors, intended for use with this property type.
97
- // throws if not found - no need for a null check
98
- var propValueConnector = ValueConnectors . Get ( propType ) ;
98
+ // fetch the right value connector from the collection of connectors, intended for use with this property type.
99
+ // throws if not found - no need for a null check
100
+ var propValueConnector = ValueConnectors . Get ( propType ) ;
99
101
100
- // pass the value, property type and the dependencies collection to the connector to get a "artifact" value
101
- var val = block . PropertyValues [ key ] ;
102
- object parsedValue = propValueConnector . ToArtifact ( val , propType , dependencies ) ;
102
+ // pass the value, property type and the dependencies collection to the connector to get a "artifact" value
103
+ var val = block . PropertyValues [ key ] ;
104
+ object parsedValue = propValueConnector . ToArtifact ( val , propType , dependencies ) ;
103
105
104
- _logger . Debug < BlockEditorValueConnector > ( "Map {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropValueConnectorType} for {PropTypeAlias}." , key , block . PropertyValues [ key ] , parsedValue , propValueConnector . GetType ( ) , propType . Alias ) ;
106
+ _logger . Debug < BlockEditorValueConnector > ( "Map {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropValueConnectorType} for {PropTypeAlias}." , key , block . PropertyValues [ key ] , parsedValue , propValueConnector . GetType ( ) , propType . Alias ) ;
105
107
106
- parsedValue = parsedValue ? . ToString ( ) ;
108
+ parsedValue = parsedValue ? . ToString ( ) ;
107
109
108
- block . PropertyValues [ key ] = parsedValue ;
110
+ block . PropertyValues [ key ] = parsedValue ;
111
+ }
109
112
}
113
+
110
114
}
111
115
112
116
value = JsonConvert . SerializeObject ( blockEditorValue ) ;
@@ -149,40 +153,45 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
149
153
{
150
154
var contentType = allContentTypes [ block . ContentTypeKey ] ;
151
155
152
- foreach ( var key in block . PropertyValues . Keys . ToArray ( ) )
156
+ if ( block . PropertyValues != null )
153
157
{
154
- var innerPropertyType = contentType . CompositionPropertyTypes . FirstOrDefault ( x => x . Alias == key ) ;
155
-
156
- if ( innerPropertyType == null )
158
+ foreach ( var key in block . PropertyValues . Keys . ToArray ( ) )
157
159
{
158
- _logger . Debug < BlockEditorValueConnector > ( "No property type found with alias {Key} on content type {ContentTypeAlias}." , key , contentType . Alias ) ;
159
- continue ;
160
- }
160
+ var innerPropertyType = contentType . CompositionPropertyTypes . FirstOrDefault ( x => x . Alias == key ) ;
161
161
162
- // fetch the right value connector from the collection of connectors, intended for use with this property type.
163
- // throws if not found - no need for a null check
164
- var propValueConnector = ValueConnectors . Get ( innerPropertyType ) ;
162
+ if ( innerPropertyType == null )
163
+ {
164
+ _logger . Debug < BlockEditorValueConnector > ( "No property type found with alias {Key} on content type {ContentTypeAlias}." , key , contentType . Alias ) ;
165
+ continue ;
166
+ }
165
167
166
- var propertyValue = block . PropertyValues [ key ] ;
168
+ // fetch the right value connector from the collection of connectors, intended for use with this property type.
169
+ // throws if not found - no need for a null check
170
+ var propValueConnector = ValueConnectors . Get ( innerPropertyType ) ;
167
171
168
- if ( propertyValue != null )
169
- {
170
- // pass the artifact value and property type to the connector to get a real value from the artifact
171
- var convertedValue = propValueConnector . FromArtifact ( propertyValue . ToString ( ) , innerPropertyType , null ) ;
172
- if ( convertedValue == null )
172
+ var propertyValue = block . PropertyValues [ key ] ;
173
+
174
+ if ( propertyValue != null )
173
175
{
174
- block . PropertyValues [ key ] = null ;
176
+ // pass the artifact value and property type to the connector to get a real value from the artifact
177
+ var convertedValue = propValueConnector . FromArtifact ( propertyValue . ToString ( ) , innerPropertyType , null ) ;
178
+ if ( convertedValue == null )
179
+ {
180
+ block . PropertyValues [ key ] = null ;
181
+ }
182
+ else
183
+ {
184
+ block . PropertyValues [ key ] = convertedValue ;
185
+ }
175
186
}
176
187
else
177
188
{
178
- block . PropertyValues [ key ] = convertedValue ;
189
+ block . PropertyValues [ key ] = propertyValue ;
179
190
}
180
191
}
181
- else
182
- {
183
- block . PropertyValues [ key ] = propertyValue ;
184
- }
185
192
}
193
+
194
+
186
195
}
187
196
188
197
return JObject . FromObject ( blockEditorValue ) ;
0 commit comments