bool INodeDeserializer.Deserialize(EventReader reader, Type expectedType, Func <EventReader, Type, object> nestedObjectDeserializer, out object value) { value = null; NodeEvent nodeEvent = reader.Peek <NodeEvent>(); bool flag = (nodeEvent != null) && this.NodeIsNull(nodeEvent); if (flag) { reader.SkipThisAndNestedEvents(); } return(flag); }
bool INodeDeserializer.Deserialize(EventReader reader, Type expectedType, Func<EventReader, Type, object> nestedObjectDeserializer, out object value) { value = null; var evt = reader.Peek<NodeEvent>(); var isNull = evt != null && NodeIsNull(evt); if (isNull) { reader.SkipThisAndNestedEvents(); } return isNull; }
bool INodeDeserializer.Deserialize(EventReader reader, Type expectedType, Func <EventReader, Type, object> nestedObjectDeserializer, out object value) { value = null; var evt = reader.Peek <NodeEvent>(); var isNull = evt != null && NodeIsNull(evt); if (isNull) { reader.SkipThisAndNestedEvents(); } return(isNull); }
bool INodeDeserializer.Deserialize(EventReader reader, Type expectedType, Func <EventReader, Type, object> nestedObjectDeserializer, out object value) { var mapping = reader.Allow <MappingStart>(); if (mapping == null) { value = null; return(false); } value = _objectFactory.Create(expectedType); while (!reader.Accept <MappingEnd>()) { var propertyName = reader.Expect <Scalar>(); var property = _typeDescriptor.GetProperty(expectedType, null, propertyName.Value, _ignoreUnmatched); if (property == null) { reader.SkipThisAndNestedEvents(); continue; } var propertyValue = nestedObjectDeserializer(reader, property.Type); var propertyValuePromise = propertyValue as IValuePromise; if (propertyValuePromise == null) { var convertedValue = TypeConverter.ChangeType(propertyValue, property.Type); property.Write(value, convertedValue); } else { var valueRef = value; propertyValuePromise.ValueAvailable += v => { var convertedValue = TypeConverter.ChangeType(v, property.Type); property.Write(valueRef, convertedValue); }; } } reader.Expect <MappingEnd>(); return(true); }
bool INodeDeserializer.Deserialize(EventReader reader, Type expectedType, Func<EventReader, Type, object> nestedObjectDeserializer, out object value) { var mapping = reader.Allow<MappingStart>(); if (mapping == null) { value = null; return false; } value = _objectFactory.Create(expectedType); while (!reader.Accept<MappingEnd>()) { var propertyName = reader.Expect<Scalar>(); var property = _typeDescriptor.GetProperty(expectedType, null, propertyName.Value, _ignoreUnmatched); if (property == null) { reader.SkipThisAndNestedEvents(); continue; } var propertyValue = nestedObjectDeserializer(reader, property.Type); var propertyValuePromise = propertyValue as IValuePromise; if (propertyValuePromise == null) { var convertedValue = TypeConverter.ChangeType(propertyValue, property.Type); property.Write(value, convertedValue); } else { var valueRef = value; propertyValuePromise.ValueAvailable += v => { var convertedValue = TypeConverter.ChangeType(v, property.Type); property.Write(valueRef, convertedValue); }; } } reader.Expect<MappingEnd>(); return true; }