public void Update() { if (canUpdate) { targetProperty.Write(targetObject, sourceProperty.Read(sourceObject)); } }
bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func <IParser, Type, object> nestedObjectDeserializer, out object value) { MappingStart mappingStart = parser.Allow <MappingStart>(); if (mappingStart == null) { value = null; return(false); } value = _objectFactory.Create(expectedType); while (!parser.Accept <MappingEnd>()) { Scalar scalar = parser.Expect <Scalar>(); IPropertyDescriptor property = _typeDescriptor.GetProperty(expectedType, null, scalar.Value, _ignoreUnmatched); if (property == null) { if (_unmatchedLogFn != null) { _unmatchedLogFn(string.Format("{2} Found a property '{0}' on a type '{1}', but that type doesn't have that property!", scalar.Value, expectedType.FullName, parser.Current.Start)); } parser.SkipThisAndNestedEvents(); } else { object obj = nestedObjectDeserializer(parser, property.Type); IValuePromise valuePromise = obj as IValuePromise; if (valuePromise == null) { object value2 = TypeConverter.ChangeType(obj, property.Type); property.Write(value, value2); } else { object valueRef = value; valuePromise.ValueAvailable += delegate(object v) { object value3 = TypeConverter.ChangeType(v, property.Type); property.Write(valueRef, value3); }; } } } parser.Expect <MappingEnd>(); return(true); }
public void Write(object target, object value) { baseDescriptor.Write(target, value); }
public void Write(object target, object value) { property.Write(holder.Read(target), value); }
public bool Deserialize(IParser parser, Type expectedType, Func <IParser, Type, object> nestedObjectDeserializer, out object value) { value = null; if (!typeof(ManagedGameObject).IsAssignableFrom(expectedType) || !parser.TryConsume(out MappingStart _)) { return(false); } bool findType = false; MappingEnd event2; Scalar scalar = parser.Consume <Scalar>(); if (scalar.Value == "MGO.Type") { string i = nestedObjectDeserializer(parser, typeof(string)) as string; expectedType = TypeByName(i); #if DEBUG debugLogger.Start("Deserialize"); debugLogger.WriteLine($"nestedObjectDeserializer : { i }"); debugLogger.WriteLine($"expectedType : { expectedType }"); debugLogger.End(); #endif if (expectedType == null) { findType = false; } else { value = objectFactory.Create(expectedType); findType = true; } } while (!parser.TryConsume(out event2)) { scalar = parser.Consume <Scalar>(); IPropertyDescriptor property = typeDescriptor.GetProperty(expectedType, null, scalar.Value, false); if (property == null || !findType) { parser.SkipThisAndNestedEvents(); continue; } object obj = nestedObjectDeserializer(parser, property.Type); IValuePromise valuePromise = obj as IValuePromise; if (valuePromise != null) { object valueRef = value; valuePromise.ValueAvailable += (Action <object>) delegate(object v) { object value3 = YamlDotNet.Serialization.Utilities. TypeConverter.ChangeType(v, property.Type); property.Write(valueRef, value3); }; } else { object value2 = YamlDotNet.Serialization.Utilities. TypeConverter.ChangeType(obj, property.Type); property.Write(value, value2); } } return(true); }