public void OnSetDefinition() { if (_definingClass == null) { throw new DesignerException("Defining class not loaded for accessing properties for class {0}", _definingClassId); } _classVersion = _definingClass.EditVersion; XmlNode classXmlNode = _definingClass.XmlData; _typeName = XmlUtil.GetNameAttribute(classXmlNode); _properties = new List <PropertyClassDescriptor>(); Dictionary <string, PropertyClass> ps = _definingClass.CustomProperties; foreach (PropertyClass p in ps.Values) { if (p.Implemented && p.AccessControl == EnumAccessControl.Public) { PropertyClass p0 = (PropertyClass)p.Clone(); p0.SetHolder(this); _properties.Add(new PropertyClassDescriptor(p0)); } } if (string.IsNullOrEmpty(_iconFilename)) { _iconFilename = SerializeUtil.ReadIconFilename(classXmlNode); } }
public PropertyItemClassPointer(string key, IClass owner, PropertyClass property) : base(key, owner) { _property = (PropertyClass)property.Clone(); _property.SetHolder(owner); _pointer = owner.VariableCustomType; if (_pointer == null) { throw new DesignerException("null VariableCustomType creating PropertyItemClassPointer"); } }
public static ActionClass createAction(IClass holder, IProperty ei, XmlObjectWriter writer, XmlNode node, IMethod scopeMethod, IActionsHolder actsHolder, Form caller) { if (ei != null) { IPropertyEx pp = ei as IPropertyEx; if (pp != null) { ActionClass act = new ActionClass(pp.RootPointer); act.ActionMethod = pp.CreateSetterMethodPointer(act); act.ActionName = act.ActionMethod.DefaultActionName; act.ActionHolder = actsHolder; if (pp.RootPointer.CreateNewAction(act, writer, scopeMethod, caller)) { return(act); } } else { PropertyClass pc = ei as PropertyClass; if (pc != null) { PropertyClass pc2 = (PropertyClass)pc.Clone(); pc2.SetHolder(holder); ActionClass act = new ActionClass(holder.RootPointer); act.ActionMethod = pc2.CreateSetterMethodPointer(act); act.ActionName = act.ActionMethod.DefaultActionName; // pc.Holder.CodeName + ".Set" + pc.Name; act.ActionHolder = actsHolder; if (holder.RootPointer.CreateNewAction(act, writer, scopeMethod, caller)) { return(act); } } else { } } } return(null); }
/// <summary> /// called from the holding class /// </summary> /// <param name="reader"></param> /// <param name="node"></param> public virtual void OnReadFromXmlNode(IXmlCodeReader reader0, XmlNode node) { XmlObjectReader reader = (XmlObjectReader)reader0; //retrieve _holder, _property UInt32 memberId = XmlUtil.GetAttributeUInt(node, XmlTags.XMLATT_PropId); //declaring property id MemberId = memberId; //id PropertyClass // UInt32 varId = XmlUtil.GetAttributeUInt(node, XmlTags.XMLATT_varId); if (varId != 0) { ClassPointer root0 = reader.ObjectList.GetTypedData <ClassPointer>(); if (root0 == null) { root0 = reader.ObjectList.Project.GetTypedData <ClassPointer>(reader.ObjectList.ClassId); if (root0 == null) { root0 = reader.ObjectList.RootPointer as ClassPointer; if (root0 == null) { MathNode.Log(TraceLogClass.MainForm, new DesignerException("Error reading CustomPropertyPointer. Class Id = {0}. More info:{1}", reader.ObjectList.ClassId, getDebugInfo(reader0, node))); } } } if (root0 != null) { LocalVariable lv = root0.GetLocalVariable(varId); _holder = lv; if (lv.ClassType == null) { MathNode.Log(TraceLogClass.MainForm, new DesignerException("Error reading CustomPropertyPointer. Local variable [{0}]'s data type is null. More info:{1}", lv, getDebugInfo(reader0, node))); } else { ClassId = lv.ClassType.DefinitionClassId; ClassPointer r = reader.ObjectList.Project.GetTypedData <ClassPointer>(ClassId); if (r == null) { MathNode.Log(TraceLogClass.MainForm, new DesignerException("Error reading CustomPropertyPointer. Class ID [{0}] of a local variable [{1}] does not point to a class. More info:{2}", ClassId, lv, getDebugInfo(reader0, node))); } else { _property = r.GetCustomPropertyById(memberId); } } } } else { XmlNode nd = node.SelectSingleNode(XmlTags.XML_ClassInstance); if (nd != null) { ClassInstancePointer cp = new ClassInstancePointer(); cp.OnPostSerialize(reader.ObjectList, nd, false, reader); if (cp.Definition == null && cp.DefinitionClassId == 0) { MathNode.Log(TraceLogClass.MainForm, new DesignerException("Error reading CustomPropertyPointer: Definition ID is 0. More info:{0}", getDebugInfo(reader0, node))); } else { if (cp.Definition == null) { MathNode.Log(TraceLogClass.MainForm, new DesignerException("Error reading CustomPropertyPointer: Definition class not found. Definition class ID = {0}. If the class was removed from the project then the places using the class should be modified. More info:{1}", cp.DefinitionClassId, getDebugInfo(reader0, node))); } else { _property = cp.Definition.GetCustomPropertyById(memberId); } _holder = cp; ClassId = cp.DefinitionClassId; } } else { UInt32 cid = XmlUtil.GetAttributeUInt(node, XmlTags.XMLATT_ownerClassID); if (cid != 0) { ClassPointer root0 = ClassPointer.CreateClassPointer(cid, reader.ObjectList.Project); _holder = root0; if (root0 == null) { MathNode.Log(TraceLogClass.MainForm, new DesignerException("Error reading CustomPropertyPointer. Owner class ID [{0}] does not point to a class. More info:{1}", cid, getDebugInfo(reader0, node))); } else { ClassId = root0.ClassId; _property = root0.GetCustomPropertyById(memberId); } } else { if (XmlUtil.GetAttributeUInt(node, XmlTags.XMLATT_ClassID) == 0) { ClassPointer root0 = reader.ObjectList.GetTypedData <ClassPointer>(); _holder = root0; if (root0 == null) { root0 = reader.ObjectList.Project.GetTypedData <ClassPointer>(reader.ObjectList.ClassId); if (root0 == null) { root0 = reader.ObjectList.RootPointer as ClassPointer; if (root0 == null) { MathNode.Log(TraceLogClass.MainForm, new DesignerException("Error reading CustomPropertyPointer. Current class ID [{0}] does not point to a class. More info:{1}", reader.ObjectList.ClassId, getDebugInfo(reader0, node))); } } } if (root0 != null) { ClassId = root0.ClassId; _property = root0.GetCustomPropertyById(memberId); } } } } } if (_holder == null) { //==backward compatibility=========================================================== UInt32 classId = XmlUtil.GetAttributeUInt(node, XmlTags.XMLATT_ClassID); //declaring class id UInt32 holderMemberId = XmlUtil.GetAttributeUInt(node, XmlTags.XMLATT_ComponentID); ClassId = classId; //definition class //root holding class ClassPointer root = reader.ObjectList.GetTypedData <ClassPointer>(); if (root == null) { root = reader.ObjectList.Project.GetTypedData <ClassPointer>(reader.ObjectList.ClassId); if (root == null) { root = reader.ObjectList.RootPointer as ClassPointer; if (root == null) { MathNode.Log(TraceLogClass.MainForm, new DesignerException("Error reading CustomPropertyPointer. Holding class, class ID [{0}], does not point to a class. More info:{1}", reader.ObjectList.ClassId, getDebugInfo(reader0, node))); } } } // UInt32 holderClassId = XmlUtil.GetAttributeUInt(node.OwnerDocument.DocumentElement, XmlTags.XMLATT_ClassID); if (holderClassId == classId) //holder is in the same class { // if (root != null) { _property = root.GetCustomPropertyById(MemberId); if (_property != null && _property.IsStatic) { _holder = root; } } } else //holder and declarer are different classes { //root is the holding class ClassPointer declarer = ClassPointer.CreateClassPointer(classId, reader.ObjectList.Project); if (declarer == null) { MathNode.Log(TraceLogClass.MainForm, new DesignerException("Error reading CustomPropertyPointer: classId {0} does not point to a class. If the class was removed from the class then please modify places using the class. More info:{1}", classId, getDebugInfo(reader0, node))); } else { _property = declarer.GetCustomPropertyById(memberId); if (_property != null && _property.IsStatic) { _holder = declarer; } } } if (_property != null && !_property.IsStatic) { if (holderMemberId == 0 || holderMemberId == reader.ObjectList.MemberId) //not an instance { _holder = root; } else { _holder = (IClass)reader.ObjectList.GetClassRefById(holderMemberId); } if (_holder == null) { //holder is a local variable LocalVariable lv = root.GetLocalVariable(holderMemberId); _holder = lv; } _property.SetHolder(_holder); } } if (_holder == null) { MathNode.Log(TraceLogClass.MainForm, new DesignerException("Invalid property pointer [{0}]. More info:{1}", node.InnerXml, getDebugInfo(reader0, node))); } }