예제 #1
0
        //==============================================================================
        /// <summary>
        /// Get the matching <![CDATA[<model>]]> section for the macro found.
        /// </summary>
        /// <param name="xmlParse"></param>
        /// <param name="modelMacro"></param>
        /// <returns></returns>
        //==============================================================================
        protected XmlNode getModelNode(TXMLParser xmlParse, String modelMacro)
        {
            int idx_1,
                idx_2,
                posStartModelType;
            String  modelType;
            XmlNode modelNode;
            String  buf;

            XmlNode result = null;

            String sModel = "[Model";

            idx_1             = modelMacro.IndexOf(sModel);
            idx_2             = modelMacro.IndexOf("]");
            posStartModelType = idx_1 + sModel.Length;
            modelType         = modelMacro.Substring(posStartModelType, idx_2 - posStartModelType).Trim();
            //get the <Model> section for the parameters
            modelNode = xmlParse.firstElementChild(xmlParse.rootNode(), "Model");
            if (modelNode != null)
            {
                if (modelType.Length > 0)
                {
                    buf = xmlParse.getAttrValue(modelNode, "name");
                    while (modelType.ToLower() != buf.ToLower())
                    {
                        modelNode = xmlParse.nextElementSibling(modelNode, "Model");
                        buf       = xmlParse.getAttrValue(modelNode, "name");
                    }
                }
                result = modelNode;
            }
            return(result);
        }
예제 #2
0
        //==============================================================================
        /// <summary>
        /// Get a list of the dlls from the <code>;ltdll;gt</code> elements. Returns the short name.
        /// </summary>
        /// <param name="xmlParse"></param>
        /// <param name="metaDataNode"></param>
        /// <param name="dllList"></param>
        //==============================================================================
        protected void getDllList(TXMLParser xmlParse, XmlNode metaDataNode, List <String> dllList)
        {
            XmlNode anode;
            String  compDll;

            anode = xmlParse.firstElementChild(metaDataNode, "dll");
            while (anode != null)
            {
                if (anode != null)
                {
                    compDll = xmlParse.getText(anode);
                    compDll = fixDllMacros(compDll);
                    dllList.Add(compDll);
                }
                anode = xmlParse.nextElementSibling(anode, "dll");
            }
        }
예제 #3
0
        //==============================================================================
        /// <summary>
        /// Loop through any <![CDATA[<component>]]> items and find the one that matches the
        /// dll name chosen.
        /// </summary>
        /// <param name="xmlParse"></param>
        /// <param name="parentNode"></param>
        /// <param name="metaDllPath"></param>
        /// <param name="dllPath"></param>
        /// <returns></returns>
        //==============================================================================
        protected XmlNode FindCompNode(TXMLParser xmlParse, XmlNode parentNode, String metaDllPath, String dllPath)
        {
            String  testDll;
            XmlNode anode;
            String  compPath;

            XmlNode result = null;

            testDll = Path.GetFileName(dllPath).ToLower();
            anode   = xmlParse.firstElementChild(parentNode, "component");
            while ((anode != null) && (result == null))
            {
                compPath = GetDllPathString(xmlParse, anode, metaDllPath);  //returns full path of dll found in <component> section
                if (testDll == Path.GetFileName(compPath).ToLower())
                {
                    result = anode;
                }
                anode = xmlParse.nextElementSibling(anode, "component");
            }
            return(result);
        }
예제 #4
0
        //=======================================================================
        /// <summary>
        /// Construct a component event object using XML description.
        /// </summary>
        /// <param name="sXML">XML description that contains the DDML of the type.</param>
        //=======================================================================
        public TCompEvent(String sXML)
        {
            TXMLParser parser;
            XmlNode    anode;
            String     typeText;

            parser     = new TXMLParser(sXML);
            sDescr     = "";
            sFullDescr = "";

            //build a DDML type from the values in the event description
            typeText = "<type>";
            anode    = parser.firstElementChild(parser.rootNode(), "field");
            bIsEmpty = (anode == null);
            while (anode != null)
            {
                typeText = typeText + parser.docToString(anode);
                anode    = parser.nextElementSibling(anode, "field");
            }
            typeText = typeText + "</type>";

            initType = new TDDMLValue(typeText, "");                   //create as a DDML type
            Name     = parser.getAttrValue(parser.rootNode(), "name"); //set this object's attributes
            sKind    = parser.getAttrValue(parser.rootNode(), "kind");
            sDescr   = parser.getAttrValue(parser.rootNode(), "descr");

            if (sKind.Length < 1)
            {
                sKind = "published";      // Default when not specified
            }
            order = 0;                    //init to an invalid value
            anode = parser.firstElementChild(parser.rootNode(), "description");
            if (anode != null)
            {
                sFullDescr = parser.getText(anode);
            }
        }
예제 #5
0
        /// <summary>
        /// Parses a &lt;parameters&gt; or &lt;set&gt; element in an XML parameter document          
        /// </summary>
        /// <param name="Parser"></param>
        /// <param name="aNode"></param>
        /// <param name="Params"></param>
        /// <param name="bModify"></param>
        private void readParamNode(TXMLParser Parser, XmlNode aNode, ref TParameterSet Params, bool bModify)
        {
            XmlNode childNode;
            TParameterSet newParams;
            string sTag,
            sValues,
            sChildName,
            sLang,
            sDummy;

            try
            {
                Params.sName = Parser.getAttrValue(aNode, "name");                        // Name and version information. The
                Params.sEnglishName = Params.sName;
                if (Params.bRootNode())                                                     //   version is passed to child sets
                    Params.sVersion = Parser.getAttrValue(aNode, "version");               //   during creation

                childNode = Parser.firstElementChild(aNode, "translate");                 // See if tbere's a translation of the name matching our current language setting
                while (childNode != null)
                {
                    sLang = Parser.getAttrValue(childNode, "lang");
                    sDummy = Parser.getText(childNode);
                    Params.addTranslation(sLang, sDummy);
                    childNode = Parser.nextElementSibling(childNode, "translate");
                }

                if (!bModify)                                                           // If we are not modifying an existing
                    while (Params.iChildCount() > 0)                                           //   parameter set, then clear any old
                        Params.deleteChild(Params.iChildCount() - 1);                              //   child parameter sets

                sValues = Parser.getAttrValue(aNode, "locales").Trim();                     // Populate the locale list
                Params.setLocaleText(sValues);

                childNode = Parser.firstElementChild(aNode, "par");                       // Parse the <par> elements
                while (childNode != null)
                {
                    sTag = Parser.getAttrValue(childNode, "name");
                    sValues = Parser.getText(childNode);
                    readParamValues(ref Params, sTag, sValues, bModify);
                    childNode = Parser.nextElementSibling(childNode, "par");
                }
                Params.deriveParams();

                childNode = Parser.firstElementChild(aNode, "set");                       // Create child parameter sets from the
                while (childNode != null)                                                   //   <set> elements
                {
                    if (!bModify)
                        newParams = Params.addChild();
                    else
                    {                                                                      // If we are modifying an existing
                        sChildName = Parser.getAttrValue(childNode, "name");                  //  parameter set, then locate the child
                        newParams = Params.getChild(sChildName);                              //   set that we are about to parse
                        if (newParams == null)
                            newParams = Params.addChild();
                    }
                    readParamNode(Parser, childNode, ref newParams, bModify);
                    childNode = Parser.nextElementSibling(childNode, "set");
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }