Exemple #1
0
        public IObjectClone CloneObject(object obj)
        {
            IObjectManager om    = this.Context.ObjectManager;
            IObjectClone   clone = new ObjectClone();

            IClassMap classMap = this.Context.DomainMap.MustGetClassMap(obj.GetType());

            foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
            {
                if (propertyMap.IsCollection)
                {
                }
                else
                {
                    if (om.HasOriginalValues(obj, propertyMap.Name))
                    {
                        clone.SetPropertyValue(propertyMap.Name, om.GetPropertyValue(obj, propertyMap.Name));
                        clone.SetOriginalPropertyValue(propertyMap.Name, om.GetOriginalPropertyValue(obj, propertyMap.Name));
                        clone.SetNullValueStatus(propertyMap.Name, om.GetNullValueStatus(obj, propertyMap.Name));
                        clone.SetUpdatedStatus(propertyMap.Name, om.GetUpdatedStatus(obj, propertyMap.Name));
                    }
                }
            }

            clone.SetObjectStatus(om.GetObjectStatus(obj));

            this.clonedObjects.Add(obj);

            return(clone);
        }
Exemple #2
0
        public IObjectClone CloneObject(object obj)
        {
            IObjectManager om    = this.Context.ObjectManager;
            IObjectClone   clone = new ObjectClone();

            IClassMap classMap = this.Context.DomainMap.MustGetClassMap(obj.GetType());

            foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
            {
                if (propertyMap.IsCollection)
                {
                    //TODO: Implement this
                }
                else
                {
                    clone.SetPropertyValue(propertyMap.Name, om.GetPropertyValue(obj, propertyMap.Name));
                    clone.SetNullValueStatus(propertyMap.Name, om.GetNullValueStatus(obj, propertyMap.Name));
                    clone.SetUpdatedStatus(propertyMap.Name, om.GetUpdatedStatus(obj, propertyMap.Name));

                    if (om.HasOriginalValues(obj, propertyMap.Name))
                    {
                        clone.SetOriginalPropertyValue(propertyMap.Name, om.GetOriginalPropertyValue(obj, propertyMap.Name));
                    }
                }
            }

            clone.SetObjectStatus(om.GetObjectStatus(obj));

            IIdentityHelper identityHelper = obj as IIdentityHelper;

            if (identityHelper != null)
            {
                clone.SetIdentity(identityHelper.GetIdentity());

                if (identityHelper.HasIdentityKeyParts())
                {
                    foreach (object keyPart in identityHelper.GetIdentityKeyParts())
                    {
                        clone.GetIdentityKeyParts().Add(keyPart);
                    }
                }
                if (identityHelper.HasKeyStruct())
                {
                    clone.SetKeyStruct(identityHelper.GetKeyStruct());
                }
            }

            this.clonedObjects.Add(obj);

            return(clone);
        }