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); }
public virtual PropertyStatus GetPropertyStatus(object obj, string propertyName) { ObjectStatus objStatus = m_ObjectManager.GetObjectStatus(obj); if (objStatus == ObjectStatus.UpForCreation) { return(PropertyStatus.Dirty); } if (objStatus == ObjectStatus.Deleted) { return(PropertyStatus.Deleted); } if (m_ObjectManager.IsDirtyProperty(obj, propertyName)) { return(PropertyStatus.Dirty); } if (m_ObjectManager.HasOriginalValues(obj, propertyName)) { return(PropertyStatus.Clean); } return(PropertyStatus.NotLoaded); }
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); }