Ejemplo n.º 1
0
        }//_ValidateAdd

        protected void _ValidateAdd(
            XmlDocument doc, 
            string sParentXPath, 
            string componentType,
            Component.eComponentType eComponentType,
            string name)
        {
            try {
                lastValidateAddComponentType = componentType;

                //creating child xml element
                String baseType = this._GetBaseComponentType(componentType);
                lastValidateAddBaseType = baseType;

                if (baseType != null) // replace with base for validation
            {
                    componentType = baseType;
                }

                XmlElement childXml = doc.CreateElement(componentType);
                //creating attributes
                XmlAttribute attributeType = doc.CreateAttribute(XmlSchemaConstants.Config.eType);
                attributeType.Value = eComponentType.ToString();
                XmlAttribute attributeName = doc.CreateAttribute(XmlSchemaConstants.Config.Name);
                attributeName.Value = name;
                //adding attributes
                childXml.SetAttributeNode(attributeType);
                childXml.SetAttributeNode(attributeName);

                // use 'base' of component type to find in validated document
                lastValidateAddComponentXPath = lastValidateAddComponentXPath + "/" + componentType; // cache will use this

                doc = AddChildAtXPath(doc, sParentXPath, childXml, true);

                this._Validate(doc, componentType); //Validating the XmlDocument
            }
            catch (Exception) {
                throw;
            }
        }//_ValidateAdd
Ejemplo n.º 2
0
        }//_GetXmlTree

        public XmlElement CommonElementCreate(XmlDocument doc, int id, int? linkID, String baseType, String type, String name, String desc, Component.eComponentType eType)
        {
            int? iClassID = null;
            int? iSubClassID = null;
            DataRow drClass = null;
            DataRow drSubClass = null;

            //creating element
            XmlElement xmlElement = doc.CreateElement(XmlSchemaConstants.Display.sComponent);

            //creating attributes
            XmlAttribute attrCompType = doc.CreateAttribute(XmlSchemaConstants.Display.Component.Type);
            attrCompType.Value = type;

            XmlAttribute attrCompID = doc.CreateAttribute(XmlSchemaConstants.Display.Component.Id);
            attrCompID.Value = id.ToString();

            XmlAttribute attrCompName = doc.CreateAttribute(XmlSchemaConstants.Display.Component.Name);
            attrCompName.Value = name;

            XmlAttribute attrCompDesc = doc.CreateAttribute(XmlSchemaConstants.Display.Component.Description);
            attrCompDesc.Value = desc;

            XmlAttribute attCompEtype = doc.CreateAttribute(XmlSchemaConstants.Display.Component.eType);
            attCompEtype.Value = eType.ToString();

            //adding attributes
            xmlElement.SetAttributeNode(attrCompType);
            xmlElement.SetAttributeNode(attrCompID);
            xmlElement.SetAttributeNode(attrCompName);
            xmlElement.SetAttributeNode(attrCompDesc);
            xmlElement.SetAttributeNode(attCompEtype);

            //Base Component Type attribute
            if (baseType != null)
            {
                XmlAttribute attrBaseCompType = doc.CreateAttribute(XmlSchemaConstants.Display.Component.BaseType);
                attrBaseCompType.Value = baseType;
                xmlElement.SetAttributeNode(attrBaseCompType);
            }//Base Component Type attribute

            //LinkID attribute

            if (linkID.HasValue)
            {
                XmlAttribute attrLinkID = doc.CreateAttribute(XmlSchemaConstants.Display.Component.LinkID);
                attrLinkID.Value = linkID.Value.ToString();

                xmlElement.SetAttributeNode(attrLinkID);
            }

            //class & subclass components and their ids
            this._GetClassSubclass(id, eType, out drClass, out drSubClass);
            if (drClass != null)
            {
                iClassID = (int)drClass[SchemaConstants.Id];
            }
            if (drSubClass != null)
            {
                iSubClassID = (int)drSubClass[SchemaConstants.Id];
            }
            
            //if (compOptions.InstanceUseClassName)
            //{
            //    // check use class name controller variable
            //    //ComponentIDName classIDName = this.CheckUseClassName(iCompID, eCompEtype);
            //    if (drClass != null)
            //    {
            //        string key = drClass[SchemaConstants.Id].ToString();

            //        string valueCheck = GetCacheValue(key, Component.Class.InstancesUseClassName.Name, eParamParentType.Component);
            //        if (valueCheck != null)
            //        {
            //            if (valueCheck.Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase))
            //            {
            //                xmlElement.Attributes[XmlSchemaConstants.Display.Component.Name].Value = drClass[SchemaConstants.Name].ToString();
            //            }
            //        }
            //        else
            //        {
            //            ComponentIDName classIDName = this.CheckUseClassName(drClass);

            //            if (classIDName != null)
            //            {
            //                xmlElement.Attributes[XmlSchemaConstants.Display.Component.Name].Value = classIDName.Name;
            //            }
            //        }
            //    }
            //}//if user is asking to use class name for instances

            if (iClassID.HasValue)
            {
                XmlAttribute attrClassID = doc.CreateAttribute(XmlSchemaConstants.Display.Component.ClassID);
                attrClassID.Value = iClassID.Value.ToString();

                xmlElement.SetAttributeNode(attrClassID);
            }//if classInstanceInfo

            if (iSubClassID.HasValue)
            {
                XmlAttribute attrSubclassID = doc.CreateAttribute(XmlSchemaConstants.Display.Component.SubclassID);
                attrSubclassID.Value = iSubClassID.Value.ToString();

                xmlElement.SetAttributeNode(attrSubclassID);
            }//SubclassInstanceInfo

            return xmlElement;
        }