Example #1
0
        // used by cache 
        protected XmlElement CreateCacheElement(Controller c, XmlDocument doc, int id, int linkID, String type, String baseType, String name, String desc, Component.eComponentType eType, List<ComponentFunction> lastSchemaValuesValidateAdd)
        {
            // shared with controller_xml
            XmlElement newCacheElement = c.CommonElementCreate(doc, id, linkID, baseType, type, name, desc, eType);

            // parameters take an id instead of a component_row - a little different
            IXPathNavigable compClone = c.GetParametersForComponent(id);
            if (compClone != null)
            {
                XmlNode insert = ((XmlNode)compClone).SelectSingleNode(XmlSchemaConstants.Display.sComponentParameters);
                insert = doc.ImportNode(insert, true);
                newCacheElement.AppendChild(insert);
            }

            IXPathNavigable linkClone = c.GetParametersForLink(linkID);

            if (linkClone != null)
            {
                XmlNode insert = ((XmlNode)linkClone).SelectSingleNode(XmlSchemaConstants.Display.sLinkParameters);
                insert = doc.ImportNode(insert, true);
                newCacheElement.AppendChild(insert);
            }

            // Functions also slightly different, come from the last schema values from the ValidateAdd call
            if (lastSchemaValuesValidateAdd != null && lastSchemaValuesValidateAdd.Count > 0)
            {
                //creating "Functions" element
                XmlElement funcsElement = doc.CreateElement(XmlSchemaConstants.Display.sFunction + "s");    //Functions
                foreach (ComponentFunction func in lastSchemaValuesValidateAdd)
                {
                    //adding "Function" element to "Functions" element
                    XmlElement xmlElementFunc = c.CreateXmlFunction(doc, func.Name, func.Action, "" + func.Visible);
                    funcsElement.AppendChild(xmlElementFunc);
                }
                newCacheElement.AppendChild(funcsElement);
            }//if functions
            return newCacheElement;
        }