コード例 #1
0
ファイル: cmpprop.cs プロジェクト: usqiage/APSIMClassic
        //=======================================================================
        /// <summary>
        /// Creates a driving property object using the XML describing the property.
        /// </summary>
        /// <param name="sXML">XML for the driving property containing the DDML type.</param>
        //=======================================================================
        public TCompDriver(String sXML)
        {
            TSDMLParser parser;
            XmlNode     anode;
            String      sBuf;

            sDescr     = "";
            sFullDescr = "";

            parser   = new TSDMLParser(sXML);
            anode    = parser.firstElementChild(parser.rootNode(), "type");
            initType = new TDDMLValue(parser, anode, "");

            FName         = parser.getAttrValue(parser.rootNode(), "name");
            initType.Name = FName;
            sDescr        = parser.getAttrValue(parser.rootNode(), "descr");

            FMinConn = 1; // Default
            sBuf     = parser.getAttrValue(parser.rootNode(), "minsrc");
            if (sBuf.Trim().Length > 0)
            {
                FMinConn = Convert.ToInt32(sBuf);
            }
            FMaxConn = 1; // Default
            sBuf     = parser.getAttrValue(parser.rootNode(), "maxsrc");
            if (sBuf.Trim().Length > 0)
            {
                FMaxConn = Convert.ToInt32(sBuf);
            }
            anode = parser.firstElementChild(parser.rootNode(), "description");
            if (anode != null)
            {
                sFullDescr = parser.getText(anode);
            }
        }
コード例 #2
0
ファイル: cmpprop.cs プロジェクト: usqiage/APSIMClassic
        //=======================================================================
        /// <summary>
        /// Creates a component property from the XML description of a property.
        /// </summary>
        /// <param name="sXML">XML for the property containing the DDML type. e.g.
        /// &lt;property name=&quot;name&quot; access=&quot;read&quot; init=&quot;F&quot;&gt;
        ///   &lt;type kind=&quot;string&quot;&gt;&lt;defval&gt;&lt;/defval&gt;
        ///   &lt;/type&gt;
        /// &lt;/property&gt;
        /// </param>
        //=======================================================================
        public TCompProperty(String sXML)
        {
            TSDMLParser parser;
            String      access;
            XmlNode     anode;

            //create a parser. (not very nice creating a second parser but....)
            parser    = new TSDMLParser(sXML);
            anode     = parser.firstElementChild(parser.rootNode(), "type");
            InitValue = new TInitValue(parser, anode, "");

            bRead      = false;
            bWrite     = false;
            bInit      = false;
            sDescr     = "";
            sFullDescr = "";

            Name           = parser.getAttrValue(parser.rootNode(), "name");
            InitValue.Name = Name;
            sDescr         = parser.getAttrValue(parser.rootNode(), "descr");
            access         = parser.getAttrValue(parser.rootNode(), "access");
            if (access == "both")
            {
                bRead  = true;
                bWrite = true;
            }
            if ((access == "read") || (access.Length == 0))
            {
                bRead = true;
            }
            if (access == "write")
            {
                bWrite = true;
            }
            if (parser.getAttrValue(parser.rootNode(), "init") == "T")
            {
                bInit = true;
                initialiseMembers(InitValue);
            }
            anode = parser.firstElementChild(parser.rootNode(), "description");
            if (anode != null)
            {
                sFullDescr = parser.getText(anode);
            }
        }
コード例 #3
0
        //=========================================================================
        /// <summary>
        /// Initialise the component's properties from the SDML init section.
        /// </summary>
        /// <param name="sdml">The SDML for the init section.</param>
        //=========================================================================
        public void setXML(string sdml)
        {
            XmlNode anode;

            TSDMLParser parser = new TSDMLParser(sdml);

            anode = parser.firstElementChild(parser.rootNode(), "init");
            while (anode != null)
            {
                TSDMLValue sdmlVal = new TSDMLValue(parser, anode, "");
                writeValue(sdmlVal.Name, sdmlVal);

                anode = parser.nextElementSibling(anode, "init");
            }
        }