//============================================================================== /// <summary> /// Searching for a suitable model class name. /// </summary> /// <param name="xmlParse"></param> /// <param name="modelNode"></param> /// <param name="compDll"></param> /// <returns></returns> //============================================================================== protected String findCompClassName(TXMLParser xmlParse, XmlNode modelNode, String compDll) { XmlNode aNode; String attrVal; String result = ""; if (modelNode != null) { aNode = xmlParse.firstElementChild(modelNode, "Cultivar"); if (aNode != null) { attrVal = xmlParse.getAttrValue(aNode, "name"); result = attrVal; } else { aNode = xmlParse.firstElementChild(modelNode, "crop_type"); if (aNode != null) { result = xmlParse.getText(aNode); } if (result.Length < 1) //if this is a non plant then { result = xmlParse.getAttrValue(modelNode, "name"); //try the model type } if (result.Length < 1) //if this is a non plant and non soil then { result = xmlParse.getAttrValue(xmlParse.rootNode(), "name"); //try the Type } } } return(result); }
//============================================================================== /// <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"); } }
//======================================================================= /// <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); } }
/// <summary> /// Parses a <parameters> or <set> 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); } }