Exemple #1
0
 protected override void OnSetImage()
 {
     if (_property == null && Designer != null)
     {
         ClassPointer root = Designer.GetRootId();
         _property = root.GetCustomPropertyById(PropertyId);
     }
     if (_property != null)
     {
         if (_property.RunAt == EnumWebRunAt.Client)
         {
             SetIconImage(Resources._custPropClient.ToBitmap());
         }
         else if (_property.RunAt == EnumWebRunAt.Server)
         {
             SetIconImage(Resources._custPropServer.ToBitmap());
         }
         else
         {
             SetIconImage(Resources._custProp.ToBitmap());
         }
     }
     else
     {
         SetIconImage(Resources._custProp.ToBitmap());
     }
 }
Exemple #2
0
        public override void OnReadFromXmlNode(IXmlCodeReader serializer, XmlNode node)
        {
            base.OnReadFromXmlNode(serializer, node);
            PropertyId      = XmlUtil.GetAttributeUInt(node, XMLATTR_PropertyId);
            PropertyClassId = XmlUtil.GetAttributeUInt(node, XmlTags.XMLATT_ClassID);
            XmlObjectReader reader = (XmlObjectReader)serializer;

            if (PropertyClassId == 0)
            {
                PropertyClassId = reader.ObjectList.ClassId;
            }
            ClassPointer root = ClassPointer.CreateClassPointer(PropertyClassId, reader.ObjectList.Project);

            PropertyClass mc = root.GetCustomPropertyById(PropertyId);

            if (mc == null)
            {
                MathNode.LogError(string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                "Property {0} not found in class {1}", PropertyId, root.ClassId));
            }
            else
            {
                _property = mc;
            }
        }
Exemple #3
0
        /// <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)));
            }
        }