Example #1
0
File: XML.cs Project: Delphboy/F454
        //split an XML string into elements -> returns the specified element
        public XmlNodeList splitXML(string XMLString, XMLTag xmlType)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(XMLString);
            return(xmlDoc.GetElementsByTagName(xmlType.ToString()));
        }
Example #2
0
        private void SaveProject(string path)
        {
            XMLTree tree   = new XMLTree("1.0", System.Text.Encoding.UTF8);
            XMLTag  tgProj = tree.MainTag.AddChild("Project");

            tgProj.AddChild("namespace").Body = GlobalData.GlobalProject.ProjectName;
            XMLTag tgClasses = tgProj.AddChild("Classes");

            foreach (SmartB1tCSClass cs in GlobalData.GlobalProject.Classes)
            {
                XMLTag tgCS = tgClasses.AddChild("Class");
                tgCS.AddChild("name").Body = cs.ClassName;
                XMLTag tgVars = tgCS.AddChild("Vars");
                foreach (SmartB1tCSVar csv in cs.Fields)
                {
                    XMLTag tgVarData = tgVars.AddChild("Var");
                    tgVarData.AddChild("name").Body        = csv.VarName;
                    tgVarData.AddChild("custom_type").Body = csv.IsCustomType.ToString();
                    tgVarData.AddChild("data_type").Body   = csv.DataType;
                }
            }
            tree.SaveTo(path);
            MessageBox.Show("Project saved.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #3
0
    internal Hashtable GetAllSettings(string sSections)
    {
        Hashtable hashtable = new Hashtable();

        string[] array;
        if (Strings.InStr(sSections, Conversions.ToString(this.m_crSectionSeparator), CompareMethod.Binary) != 0)
        {
            array = Strings.Split(sSections, Conversions.ToString(this.m_crSectionSeparator), -1, CompareMethod.Binary);
        }
        else
        {
            array = new string[]
            {
                sSections
            };
        }
        checked
        {
            try
            {
                string[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    string  text    = array2[i];
                    XmlNode xmlNode = this.m_objXMLDoc.SelectSingleNode("//Section[@Name='" + text + "']");
                    if (xmlNode != null)
                    {
                        XmlNodeList xmlNodeList = xmlNode.SelectNodes("descendant::Key");
                        if (xmlNodeList != null)
                        {
                            try
                            {
                                IEnumerator enumerator = xmlNodeList.GetEnumerator();
                                while (enumerator.MoveNext())
                                {
                                    XmlNode xmlNode2 = (XmlNode)enumerator.Current;
                                    XMLTag  xMLTag   = new XMLTag();
                                    xMLTag.Name    = xmlNode2.Attributes["Name"].Value;
                                    xMLTag.Value   = xmlNode2.Attributes["Value"].Value;
                                    xMLTag.Section = text;
                                    hashtable.Add(xmlNode2.Attributes["Name"].Value, xMLTag);
                                }
                            }
                            finally
                            {
                                IEnumerator enumerator = null;
                                if (enumerator is IDisposable)
                                {
                                    (enumerator as IDisposable).Dispose();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception expr_140)
            {
                ProjectData.SetProjectError(expr_140);
                ProjectData.ClearProjectError();
            }
            return(hashtable);
        }
    }