public ArraySetOperation(int index, object reference) { this.index = index; referenceValue = ((IList)reference)[index]; type = GetType(referenceValue); isValue = type == null ? false : type.IsValueType; isPure = type == null || type.IsPure(); operations = isPure ? null : InitializationUtility.GetInitializer(type).CreateOperations(referenceValue); }
public FieldSetOperation(IFieldWrapper field, object reference) { this.field = field; referenceValue = field.Get(ref reference); type = GetType(referenceValue); isValue = type == null ? false : type.IsValueType; isPure = type == null || type.IsPure(); operations = isPure ? null : InitializationUtility.GetInitializer(type).CreateOperations(referenceValue); }
protected override void Initialize(ref T instance, T reference, HashSet <object> toIgnore) { for (int i = 0; i < instance.Count; i++) { var instanceValue = instance[i]; var referenceValue = reference[i]; if (referenceValue is ValueType || referenceValue != null) { var initializer = InitializationUtility.GetInitializer(referenceValue.GetType()); initializer.Initialize(ref instanceValue, referenceValue, toIgnore); instance[i] = instanceValue; } else { instance[i] = referenceValue; } } }
protected override void Initialize(ref object instance, object reference, HashSet <object> toIgnore) { for (int i = 0; i < fields.Length; i++) { var field = fields[i]; var instanceValue = field.Get(ref instance); var referenceValue = field.Get(ref reference); if (isValue || referenceValue != null) { var initializer = InitializationUtility.GetInitializer(referenceValue.GetType()); initializer.Initialize(ref instanceValue, referenceValue, toIgnore); field.Set(ref instance, instanceValue); } else { field.Set(ref instance, referenceValue); } } }