public TProperty GetValue <TProperty>(PropertyInfo propertyInfo, Func <TProperty> defaultFactory) { var type = this.node.ValueType; var targetProp = type.TypeResolver.FromProperty(type, propertyInfo); PropertyContainer propContainer; if (!this.propertyDict.TryGetValue(targetProp.JsonName, out propContainer)) { if (defaultFactory == null) { this.node.Context.OnMissingRequiredPropertyError(this.node, targetProp); throw new PomonaSerializationException("Missing required property " + targetProp.JsonName + " in json."); } return(defaultFactory()); } var propNode = new PropertyValueDeserializerNode(this.node, targetProp); this.deserializer.DeserializeThroughContext(propNode, new Reader(propContainer.JProperty.Value)); propContainer.Fetched = true; return((TProperty)propNode.Value); }
private void DeserializeRemainingProperties() { foreach (var prop in this.node.ValueType.Properties) { PropertyContainer propContainer; if (this.propertyDict.TryGetValue(prop.JsonName, out propContainer) && !propContainer.Fetched) { var propNode = new PropertyValueDeserializerNode(this.node, prop) { Operation = propContainer.Operation }; var oldValue = propNode.Value = propNode.Property.GetValue(this.node.Value, propNode.Context); this.deserializer.DeserializeThroughContext(propNode, new Reader(propContainer.JProperty.Value)); var newValue = propNode.Value; if (oldValue != newValue) { this.node.SetProperty(prop, newValue); } propContainer.Fetched = true; } } }