Example #1
0
      //============================================================================
      /// <summary>
      /// Reads the fields/elements from the SDML value.
      /// </summary>
      //============================================================================
      protected override void getFldElemList()
      {
         TSDMLValue newMember;
         XmlNode memberNode;
         XmlNode valNode;
         String strVal;

         //builds the child list using the parent's parser and just shifts the
         //parser's topElement domnode respectively.
         memberNode = parser.firstMember(parser.rootNode()); //looks for <element> or <field> children

         //while more <element> or <field> children
         while (memberNode != null) {
            newMember = new TSDMLValue(parser, memberNode, "");
            FMembers.Add(newMember);    //add to the list of children

            memberNode = parser.nextMember(memberNode);
         }

         //----------------------------------------------------------------
         //Scalar arrays may have values as a list of <val> elements
         if (FIsArray && (FBaseType != TTypedValue.TBaseType.ITYPE_DEF) && (count() == 0))
         {
            valNode = parser.firstElementChild(parser.rootNode(), "val");
            while (valNode != null) { //for each <val> node
               strVal = parser.getText(valNode);   //get the string from the <val></val>
               //create a child of the parent's type with this value
               newMember = (TSDMLValue)addScalar("", FBaseType);
               newMember.setValue(strVal);
               valNode = parser.nextElementSibling(valNode, "val");
            }  //next <val>
         }

      }
Example #2
0
        //==============================================================================
        /// <summary>
        /// Convert an init script into the relevant properties.
        /// </summary>
        /// <param name="sScriptName">Name of the script.</param>
        /// <param name="sScriptText">XML text of the init script
        /// &lt;initsection&gt;
        ///      &lt;init..... /&gt;
        ///   &lt;/initsection&gt;
        ///</param>
        // N.Herrmann Feb 2007
        //==============================================================================
        public void textToInitScript(string sScriptName, string sScriptText)
        {
            uint       initCount;
            string     buf;
            uint       i;
            TDDMLValue ddmlVal;
            TSDMLValue sdmlVal;

            Byte []     data;
            TInitParser initSection;

            int index = getScriptIndex(sScriptName);

            if (index < 0)
            {
                createInitScript(sScriptName);
            }

            scriptList[index].scriptText = sScriptText;          //set the text string for the script
            scriptList[index].propertyList.Clear();              //remove all the properties
            //now get all the sdml properties from the initsection
            initSection = new TInitParser(sScriptText);          //parse the <initsection>
            ddmlVal     = new TDDMLValue("<empty/>", "defined"); //used for getting the ddml type
            initCount   = initSection.initCount();
            for (i = 1; i <= initCount; i++)
            {                                                       //for each init value
                buf     = initSection.initText(i);                  //the sdml xml
                sdmlVal = new TSDMLValue(buf, "");                  //new sdml type
                data    = new Byte[sdmlVal.sizeBytes()];
                sdmlVal.getData(ref data);                          //get the datablock
                //add this property to the script. (a little inneficient here)
                valueToInitScript(sScriptName, sdmlVal.Name, ddmlVal.getText(sdmlVal, 0, 2), data);
            }
        }
Example #3
0
        //============================================================================
        /// <summary>
        /// Uses the copy constructor to make a clone of a typedvalue's structure.
        /// It is then added as a member to an array or record.
        /// this virtual function is expected to be overriden so that new members are
        /// of the child classes' type.
        /// </summary>
        /// <param name="bluePrintValue">Use this typed value as the blue print.</param>
        //============================================================================
        public override void newMember(TTypedValue bluePrintValue)
        {
            TSDMLValue newElement;

            newElement = new TSDMLValue(bluePrintValue); //calls copy constructor
            addMember(newElement);                       //add the copy
        }
Example #4
0
        //============================================================================
        /// <summary>
        /// Reads the fields/elements from the SDML value.
        /// </summary>
        //============================================================================
        protected override void getFldElemList()
        {
            TSDMLValue newMember;
            XmlNode    memberNode;
            XmlNode    valNode;
            String     strVal;

            //builds the child list using the parent's parser and just shifts the
            //parser's topElement domnode respectively.
            memberNode = parser.firstMember(parser.rootNode()); //looks for <element> or <field> children

            //while more <element> or <field> children
            while (memberNode != null)
            {
                newMember = new TSDMLValue(parser, memberNode, "");
                FMembers.Add(newMember); //add to the list of children

                memberNode = parser.nextMember(memberNode);
            }

            //----------------------------------------------------------------
            //Scalar arrays may have values as a list of <val> elements
            if (FIsArray && (FBaseType != TTypedValue.TBaseType.ITYPE_DEF) && (count() == 0))
            {
                valNode = parser.firstElementChild(parser.rootNode(), "val");
                while (valNode != null)               //for each <val> node
                {
                    strVal = parser.getText(valNode); //get the string from the <val></val>
                    //create a child of the parent's type with this value
                    newMember = (TSDMLValue)addScalar("", FBaseType);
                    newMember.setValue(strVal);
                    valNode = parser.nextElementSibling(valNode, "val");
                } //next <val>
            }
        }
Example #5
0
        //============================================================================
        /// <summary>
        /// Used to add a scalar to a record or array
        /// </summary>
        /// <param name="sName">Name of the scalar value.</param>
        /// <param name="aType">Use this type.</param>
        /// <returns>The scalar value added.</returns>
        //============================================================================
        public override TTypedValue addScalar(String sName, TBaseType aType)
        {
            TSDMLValue  newScalar;
            TTypedValue result = null;

            if (FIsArray || FIsRecord)
            {
                newScalar = new TSDMLValue(sName, aType);
                addMember(newScalar);
                result = newScalar;
            }
            return(result);
        }
Example #6
0
        //=========================================================================
        /// <summary>
        /// Get the whole init section as &lt;initsection&gt;&lt;/initsection&gt; .
        /// </summary>
        /// <returns>The SDML init section.</returns>
        //=========================================================================
        public string asSDML()
        {
            TSDMLValue    sdmlVal = new TSDMLValue("<type/>", "");
            StringBuilder sdml    = new StringBuilder();

            sdml.Insert(0, "<initsection>");
            for (int i = 0; i < FValues.Count; i++)
            {
                sdml.Append(sdmlVal.getText(FValues[i], 2, 2));
            }
            sdml.Append("</initsection>");

            return(sdml.ToString());
        }
Example #7
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");
            }
        }
Example #8
0
 protected TSDMLValue FSDMLWriter;       //use this object for conversion
 /// <summary>
 /// Construct a script manager.
 /// </summary>
 public TInitScriptManager(bool runningRebuild)
 {
     FRunningRebuild = runningRebuild;
     scriptList      = new List <TScriptSpec>();
     FSDMLWriter     = new TSDMLValue("<empty/>", "defined");  //use this object for conversion
 }
Example #9
0
      //============================================================================
      /// <summary>
      /// Used to add a scalar to a record or array
      /// </summary>
      /// <param name="sName">Name of the scalar value.</param>
      /// <param name="aType">Use this type.</param>
      /// <returns>The scalar value added.</returns>
      //============================================================================
      public override TTypedValue addScalar(String sName, TBaseType aType)
      {
         TSDMLValue newScalar;
         TTypedValue result = null;

         if (FIsArray || FIsRecord) {
               newScalar = new TSDMLValue(sName, aType);
               addMember(newScalar);
               result = newScalar;
         }
         return result;
      }
Example #10
0
      //============================================================================
      /// <summary>
      /// Uses the copy constructor to make a clone of a typedvalue's structure.
      /// It is then added as a member to an array or record.
      /// this virtual function is expected to be overriden so that new members are
      /// of the child classes' type.
      /// </summary>
      /// <param name="bluePrintValue">Use this typed value as the blue print.</param>
      //============================================================================
      public override void newMember(TTypedValue bluePrintValue)
      {
         TSDMLValue newElement;

         newElement = new TSDMLValue(bluePrintValue); //calls copy constructor
         addMember(newElement);  //add the copy
      }
 /// <summary>
 /// Set the init value in the document using the TSDMLValue passed in.
 /// </summary>
 /// <param name="compNode">Component node in the document</param>
 /// <param name="varName">Name of the variable in the AusFarm init section</param>
 /// <param name="init">The TTypedValue with the required settings</param>
 private void SetTypedInit(XmlNode compNode, string varName, TSDMLValue init)
 {
     if (compNode != null)
     {
         TCompParser comp = new TCompParser(compNode.OuterXml);
         if (!comp.IsAPSRU())
         {
             StringBuilder newInitSection = new StringBuilder();
             newInitSection.Append("<initsection>");
             //AusFarm inits
             //find the init node in the section
             uint i = 1;
             while (i <= comp.initCount())
             {
                 if (comp.initName(i) == varName)
                 {
                     string initStr = init.getText(init, 0, 2);
                     initStr = initStr.Replace("&#39;", "'");    //replace any escaped single quotes
                     newInitSection.Append(initStr);
                 }
                 else
                     newInitSection.Append(comp.initText(i));
                 i++;
             }
             newInitSection.Append("</initsection>");
             XmlNode initdata = compNode.SelectSingleNode("initdata");
             initdata.InnerXml = "<![CDATA[" + newInitSection.ToString() + "]]>";
         }
     }
 }
 /// <summary>
 /// Get the init sdml property from an AusFarm component's init section.
 /// </summary>
 /// <param name="compNode">The xml node for the component</param>
 /// <param name="varName">Name of the init value</param>
 /// <returns>An TSDMLValue</returns>
 private TSDMLValue GetTypedInit(XmlNode compNode, string varName)
 {
     TSDMLValue init = null;
     if (compNode != null)
     {
         TCompParser comp = new TCompParser(compNode.OuterXml);
         if (!comp.IsAPSRU())
         {
             //AusFarm inits
             string sdml = comp.initTextByName(varName);
             if (sdml.Length > 0)
             {
                 init = new TSDMLValue(sdml, "");
             }
         }
     }
     return init;
 }