public override void OnPostSerialize(ObjectIDmap objMap, XmlNode objectNode, bool saved, object serializer)
        {
            base.OnPostSerialize(objMap, objectNode, saved, serializer);
            MemberId = XmlUtility.XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_memberId);
            //load attributes from base
            ClassPointer           root = objMap.GetTypedData <ClassPointer>();
            PropertyClassInherited p    = root.GetBaseProperty(this.Name, BaseClassId, BasePropertyId);

            CopyFromInherited(p);
        }
Exemple #2
0
 public override void OnPostSerialize(ObjectIDmap objMap, XmlNode objectNode, bool saved, object serializer)
 {
     if (saved)
     {
     }
     else
     {
         if (MemberId == objMap.MemberId)
         {
             ClassPointer = objMap.GetTypedData <ClassPointer>();
         }
         else
         {
             ClassInstancePointer cr = DesignUtil.GetClassRef(WholeId, objMap);
             if (cr != null)
             {
                 ClassPointer = cr;
             }
             else
             {
                 object v = objMap.GetObjectByID(MemberId);
                 if (v == null)
                 {
                     if (objMap.Count == 0)
                     {
                     }
                     else
                     {
                         if (MemberId == 3667767822)
                         {
                             //it is the HtmlElement_body
                         }
                         else
                         {
                             //this time the object may not be available.
                         }
                     }
                 }
                 else
                 {
                     MemberComponentId mc = MemberComponentId.CreateMemberComponentId(objMap.GetTypedData <ClassPointer>(), v, MemberId, null);
                     ClassPointer = mc;
                 }
             }
         }
     }
 }
 public void OnDelayedPostSerialize(ObjectIDmap objMap, XmlNode objectNode, XmlObjectReader reader)
 {
     OnDeserialize(objMap.GetTypedData <ClassPointer>());
 }
 public IClassPointer GetClassPointerFromCache(ObjectIDmap map)
 {
     return(map.GetTypedData <ClassPointer>());
 }
 private void taskExecuter(IEventPointer eventPointer, object[] eventParameters)
 {
     try
     {
         foreach (EventAction ea in eventHandlers)
         {
             EventPointer ep = eventPointer as EventPointer;
             if (ea.Event.IsSameObjectRef(ep))
             {
                 List <ParameterClass> eventValues = new List <ParameterClass>();
                 if (eventParameters != null && eventParameters.Length > 0)
                 {
                     ParameterInfo[] pifs = ep.Parameters;
                     if (pifs.Length != eventParameters.Length)
                     {
                         throw new DesignerException("Event {0} parameter count mismatch", ep.MemberName);
                     }
                     for (int i = 0; i < pifs.Length; i++)
                     {
                         ParameterClass p = new ParameterClass(new TypePointer(pifs[i].ParameterType));
                         p.Name           = pifs[i].Name;
                         p.ObjectInstance = eventParameters[i];
                         eventValues.Add(p);
                     }
                 }
                 //execute the event handlers
                 TaskIdList actIdList = ea.TaskIDList;
                 foreach (TaskID tid in actIdList)
                 {
                     UInt32 classId = tid.ClassId;
                     //if (tid.IsGroup)
                     //{
                     //}
                     //else
                     //{
                     //find the action in the list of all actions
                     List <IAction> acts = null;
                     if (classId == _map.ClassId)
                     {
                         acts = actions;
                     }
                     else
                     {
                         ObjectIDmap classmap = _map.GetMapByClassId(classId);
                         if (classmap != null)
                         {
                             ActionEventCollection av = classmap.GetTypedData <ActionEventCollection>();
                             if (av == null)
                             {
                                 av = new ActionEventCollection(classmap);
                                 classmap.SetTypedData <ActionEventCollection>(av);
                                 av.LoadActions();
                             }
                             acts = av.actions;
                         }
                     }
                     if (acts != null)
                     {
                         foreach (IAction a in acts)
                         {
                             if (a.ActionId == tid.ActionId)
                             {
                                 a.Execute(eventValues);
                                 break;
                             }
                         }
                     }
                     //}
                 }
                 break;
             }
         }
     }
     catch (Exception err)
     {
         MathNode.Log(err);
     }
 }
Exemple #6
0
 public void OnPostSerialize(ObjectIDmap objMap, XmlNode objectNode, bool saved, object serializer)
 {
     if (saved)
     {
         XmlUtil.SetNameAttribute(objectNode, _name);
         XmlUtil.SetAttribute(objectNode, XmlTags.XMLATT_instanceId, _memberId);
         XmlUtil.SetAttribute(objectNode, XmlTags.XMLATT_ClassID, ClassId);
         ClassInstancePointer ip = _hostingClass as ClassInstancePointer;
         if (ip != null)
         {
             XmlNode nd = XmlUtil.CreateSingleNewElement(objectNode, XmlTags.XML_ClassInstance);
             ip.OnPostSerialize(objMap, nd, saved, serializer);
         }
         else
         {
             ClassPointer root = _hostingClass as ClassPointer;
             if (root != null)
             {
                 if (root.ClassId != objMap.ClassId)
                 {
                     XmlUtil.SetAttribute(objectNode, XmlTags.XMLATT_hostClassId, root.ClassId);
                 }
             }
         }
         //save custom property values
         if (_properties != null)
         {
             XmlObjectWriter writer           = (XmlObjectWriter)serializer;
             PropertyDescriptorCollection pdc = new PropertyDescriptorCollection(_properties.ToArray());
             writer.WriteProperties(objectNode, pdc, this, XmlTags.XML_PROPERTY);
         }
     }
     else
     {
         _name = XmlUtil.GetNameAttribute(objectNode);
         if (_memberId == 0)
         {
             _memberId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_instanceId);
         }
         XmlNode nd = objectNode.SelectSingleNode(XmlTags.XML_ClassInstance);
         if (nd == null)
         {
             //load _hostingClass
             if (_hostingClass == null)
             {
                 ClassPointer root;
                 UInt32       hostClassId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_hostClassId);
                 if (hostClassId == 0)
                 {
                     root = ClassPointer.CreateClassPointer(objMap);
                 }
                 else
                 {
                     if (hostClassId == objMap.ClassId)
                     {
                         root = ClassPointer.CreateClassPointer(objMap);
                     }
                     else
                     {
                         root = ClassPointer.CreateClassPointer(hostClassId, objMap.Project);
                     }
                 }
                 if (root == null)
                 {
                     throw new DesignerException("Invalid class id: {0}", hostClassId);
                 }
                 _hostingClass = root;
                 if (_definingClassId == 0)                         //ClassId may be loaded by property deserialize
                 {
                     IClassRef r = root.ObjectList.GetClassRefById(MemberId);
                     if (r != null)
                     {
                         _definingClassId = r.ClassId;
                     }
                 }
             }
             //load _definingClass
             if (_definingClass == null)
             {
                 if (_definingClassId == 0)
                 {
                     _definingClassId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_ClassID);
                 }
                 if (_definingClassId == 0)
                 {
                     ClassPointer root = (ClassPointer)_hostingClass;
                     IClassRef    r    = root.ObjectList.GetClassRefById(MemberId);
                     if (r != null)
                     {
                         _definingClassId = r.ClassId;
                     }
                 }
                 _definingClass = ClassPointer.CreateClassPointer(_definingClassId, objMap.Project);
             }
         }
         else
         {
             _definingClassId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_ClassID);
             ClassInstancePointer ip = new ClassInstancePointer();
             ip.OnPostSerialize(objMap, nd, saved, serializer);
             _hostingClass = ip;
             if (this.ClassId == 0)                     //ClassId may be loaded by property deserialize
             {
                 if (_hostingClass.Definition.ObjectList.Count == 0)
                 {
                     _hostingClass.Definition.ObjectList.LoadObjects();
                     if (_hostingClass.Definition.ObjectList.Reader.HasErrors)
                     {
                         MathNode.Log(_hostingClass.Definition.ObjectList.Reader.Errors);
                         _hostingClass.Definition.ObjectList.Reader.ResetErrors();
                     }
                 }
                 IClassRef r = _hostingClass.Definition.ObjectList.GetClassRefById(_memberId);
                 _definingClassId = r.ClassId;
             }
             if (_definingClass == null)
             {
                 _definingClass = ClassPointer.CreateClassPointer(_definingClassId, objMap.Project);
             }
         }
         if (MemberId == 0 && _definingClassId == 0)
         {
             //backward compatebility
             _definingClassId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_ClassID);
             MemberId         = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_ComponentID);
             _definingClass   = objMap.Project.GetTypedData <ClassPointer>(_definingClassId);
             _hostingClass    = objMap.GetTypedData <ClassPointer>();
         }
         if (_definingClass != null)                 //not being deleted
         {
             //load custom property definitions
             XmlObjectReader reader = _definingClass.ObjectList.Reader;
             if (reader == null)
             {
                 reader = (XmlObjectReader)serializer;
             }
             LoadProperties(reader);
             //load custom property values
             LoadCustomPropertyValues(reader, objectNode);
         }
         if (MemberId == 0)
         {
             MemberId = XmlUtil.GetAttributeUInt(objectNode, XmlTags.XMLATT_ComponentID);
         }
     }
 }