Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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;
                }
            }
        }
Beispiel #4
0
        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);
                }
            }
        }