Example #1
0
        public override void SetupCloneTargets(IEnumerable source, IEnumerable target, ICloneTargetSetup setup)
        {
            ReflectedHashsetData reflectedHashsetData = GetReflectedHashsetData(source.GetType());

            if (!reflectedHashsetData.IsDeepCopyByAssignment)
            {
                if (source == target)
                {
                    foreach (object value in source)
                    {
                        setup.HandleObject(value, value);
                    }
                }
                else
                {
                    // In a hashset, there is no defined item identity, so we cannot find an equivalent
                    // between a source item and a target item. Map the source to null, so a new target will
                    // be created during the clone operation.
                    foreach (object value in source)
                    {
                        setup.HandleObject(value, null);
                    }
                }
            }
        }
Example #2
0
        public override void ReadData(IDataReader reader)
        {
            IEnumerable hashSet = this.RealObject;

            if (hashSet != null)
            {
                ReflectedHashsetData reflectedHashsetData = GetReflectedHashsetData(hashSet.GetType());
                reflectedHashsetData.ReadDataMethod.Invoke(null, new object[] { hashSet, reader });
            }
        }
Example #3
0
        private ReflectedHashsetData GetReflectedHashsetData(Type hashSetType)
        {
            ReflectedHashsetData reflectedHashsetData;

            if (!this._reflectedData.TryGetValue(hashSetType, out reflectedHashsetData))
            {
                reflectedHashsetData = new ReflectedHashsetData(hashSetType);
                this._reflectedData.Add(hashSetType, reflectedHashsetData);
            }

            return(reflectedHashsetData);
        }
Example #4
0
        public override void CopyDataTo(IEnumerable source, IEnumerable target, ICloneOperation operation)
        {
            ReflectedHashsetData reflectedHashsetData = GetReflectedHashsetData(source.GetType());

            reflectedHashsetData.CopyDataToMethod.Invoke(null, new object[] { source, target, operation });
        }