protected virtual void SerializeInlineReferenceList(XmlNode xmlObject, object obj, IClassMap classMap, IPropertyMap propertyMap, bool creating)
        {
            IObjectManager om = this.Context.ObjectManager;
            IListManager   lm = this.Context.ListManager;

            IList list = (IList)om.GetPropertyValue(obj, propertyMap.Name);

            //Optimistic concurrency
            if (!(creating))
            {
                //Check value in xmlDoc against property original value, make sure they match
            }

            XmlNode xmlList = GetNode(xmlObject, propertyMap.GetDocElement());

            RemoveAllChildNodes(xmlList);

            foreach (object value in list)
            {
                XmlNode xmlElement = AddNode(xmlList, "item");
                SerializeInlineReferenceElement(obj, xmlElement, value);
            }

            IList orgList = lm.CloneList(obj, propertyMap, ((IList)(om.GetPropertyValue(obj, propertyMap.Name))));

            om.SetOriginalPropertyValue(obj, propertyMap.Name, orgList);
        }
        protected virtual void DeserializeInlineReferenceList(object obj, IClassMap classMap, IPropertyMap propertyMap, XmlNode xmlObject)
        {
            IObjectManager om      = this.Context.ObjectManager;
            IListManager   lm      = this.Context.ListManager;
            XmlNode        xmlList = xmlObject.SelectSingleNode(propertyMap.GetDocElement());

            IList list = (IList)om.GetPropertyValue(obj, propertyMap.Name);

            if (list == null)
            {
                list = lm.CreateList(obj, propertyMap);
                om.SetPropertyValue(obj, propertyMap.Name, list);
                IList cloneList = lm.CloneList(obj, propertyMap, list);
                om.SetOriginalPropertyValue(obj, propertyMap.Name, cloneList);
            }

            IInterceptableList mList;
            bool stackMute = false;

            mList = list as IInterceptableList;
            if (mList != null)
            {
                stackMute        = mList.MuteNotify;
                mList.MuteNotify = true;
            }

            foreach (XmlNode xmlItem in xmlList.SelectNodes("item"))
            {
                object value = ManageInlineReference(xmlObject, obj, xmlItem);;

                if (value != null)
                {
                    list.Add(value);
                }
            }

            if (mList != null)
            {
                mList.MuteNotify = stackMute;
            }

            om.SetNullValueStatus(obj, propertyMap.Name, false);
            IList clone = lm.CloneList(obj, propertyMap, list);

            om.SetOriginalPropertyValue(obj, propertyMap.Name, clone);
        }
Exemple #3
0
 protected void CopyValuesToOriginals(IPropertyMap propertyMap, IListManager lm, object obj, IObjectManager om)
 {
     if (propertyMap.IsCollection)
     {
         IList list = lm.CloneList(obj, propertyMap, ((IList)(om.GetPropertyValue(obj, propertyMap.Name))));
         om.SetOriginalPropertyValue(obj, propertyMap.Name, list);
     }
     else
     {
         if (om.GetNullValueStatus(obj, propertyMap.Name))
         {
             om.SetOriginalPropertyValue(obj, propertyMap.Name, System.DBNull.Value);
         }
         else
         {
             om.SetOriginalPropertyValue(obj, propertyMap.Name, om.GetPropertyValue(obj, propertyMap.Name));
         }
     }
 }
        protected virtual void SerializeInlineObjectList(XmlNode xmlObject, object obj, IClassMap classMap, IPropertyMap propertyMap, bool creating)
        {
            IObjectManager om = this.Context.ObjectManager;
            IListManager   lm = this.Context.ListManager;

            IList list = (IList)om.GetPropertyValue(obj, propertyMap.Name);

            XmlNode xmlList = GetNode(xmlObject, propertyMap.GetDocElement());

            RemoveAllChildNodes(xmlList);

            foreach (object value in list)
            {
                XmlNode xmlInline = AddNode(xmlObject, "item");
                SerializeInlineObjectElement(xmlObject, obj, xmlInline, value, creating);
            }

            IList orgList = lm.CloneList(obj, propertyMap, ((IList)(om.GetPropertyValue(obj, propertyMap.Name))));

            om.SetOriginalPropertyValue(obj, propertyMap.Name, orgList);
        }
		protected void CopyValuesToOriginals(IPropertyMap propertyMap, IListManager lm, object obj, IObjectManager om)
		{
			if (propertyMap.IsCollection)
			{
				IList list =   lm.CloneList(obj, propertyMap, ((IList) (om.GetPropertyValue(obj, propertyMap.Name))));
				om.SetOriginalPropertyValue(obj, propertyMap.Name, list);						
			}
			else
			{
				if (om.GetNullValueStatus(obj, propertyMap.Name))
				{
					om.SetOriginalPropertyValue(obj, propertyMap.Name, System.DBNull.Value);						
				}
				else
				{						
					om.SetOriginalPropertyValue(obj, propertyMap.Name, om.GetPropertyValue(obj, propertyMap.Name));
				}						
			}
		}
Exemple #6
0
        protected virtual void DeserializeClone(object obj, ReadOnlyClone clone)
        {
            IObjectManager   om       = this.Context.ObjectManager;
            IDomainMap       dm       = this.Context.DomainMap;
            IAssemblyManager am       = this.Context.AssemblyManager;
            IClassMap        classMap = dm.MustGetClassMap(obj.GetType());
            IListManager     lm       = this.Context.ListManager;

            foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
            {
                if (propertyMap.ReferenceType == ReferenceType.None)
                {
                    if (propertyMap.IsCollection)
                    {
                        IList values = (IList)clone.PropertyValues[propertyMap.Name];
                        IList list   = (IList)om.GetPropertyValue(obj, propertyMap.Name);

                        bool stackMute           = false;
                        IInterceptableList mList = list as IInterceptableList;
                        if (mList != null)
                        {
                            stackMute        = mList.MuteNotify;
                            mList.MuteNotify = true;
                        }
                        list.Clear();

                        foreach (object value in values)
                        {
                            list.Add(value);
                        }

                        if (mList != null)
                        {
                            mList.MuteNotify = stackMute;
                        }
                        IList cloneList = lm.CloneList(obj, propertyMap, list);
                        om.SetOriginalPropertyValue(obj, propertyMap.Name, cloneList);
                        om.SetNullValueStatus(obj, propertyMap.Name, false);
                    }
                    else
                    {
                        object value = clone.PropertyValues[propertyMap.Name];
                        om.SetPropertyValue(obj, propertyMap.Name, value);
                        om.SetOriginalPropertyValue(obj, propertyMap.Name, value);
                        om.SetNullValueStatus(obj, propertyMap.Name, (bool)clone.NullValueStatuses[propertyMap.Name]);
                    }
                }
                else
                {
                    IClassMap refClassMap = propertyMap.MustGetReferencedClassMap();
                    if (refClassMap.IsReadOnly)
                    {
                        if (propertyMap.IsCollection)
                        {
                            IList values = (IList)clone.PropertyValues[propertyMap.Name];
                            IList list   = (IList)om.GetPropertyValue(obj, propertyMap.Name);

                            bool stackMute           = false;
                            IInterceptableList mList = list as IInterceptableList;
                            if (mList != null)
                            {
                                stackMute        = mList.MuteNotify;
                                mList.MuteNotify = true;
                            }
                            list.Clear();

                            foreach (SerializedReference refId in values)
                            {
                                object value = null;
                                if (refId != null)
                                {
                                    refClassMap = dm.MustGetClassMap(refId.Type);
                                    Type refType = am.GetTypeFromClassMap(refClassMap);
                                    value = this.Context.GetObjectById(refId.Identity, refType, true);
                                    list.Add(value);
                                }
                            }

                            if (mList != null)
                            {
                                mList.MuteNotify = stackMute;
                            }
                            IList cloneList = lm.CloneList(obj, propertyMap, list);
                            om.SetOriginalPropertyValue(obj, propertyMap.Name, cloneList);
                            om.SetNullValueStatus(obj, propertyMap.Name, false);
                        }
                        else
                        {
                            object value = null;
                            SerializedReference refId = (SerializedReference)clone.PropertyValues[propertyMap.Name];
                            if (refId != null)
                            {
                                refClassMap = dm.MustGetClassMap(refId.Type);
                                Type refType = am.GetTypeFromClassMap(refClassMap);
                                value = this.Context.GetObjectById(refId.Identity, refType, true);
                            }
                            om.SetPropertyValue(obj, propertyMap.Name, value);
                            om.SetOriginalPropertyValue(obj, propertyMap.Name, value);
                            om.SetNullValueStatus(obj, propertyMap.Name, (bool)clone.NullValueStatuses[propertyMap.Name]);
                        }
                    }
                }
            }
        }