GetAttribute() public method

public GetAttribute ( int attributeIndex ) : string
attributeIndex int
return string
コード例 #1
0
 //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ�
 public bool isSuper(FileInfo obFile, FileInfo obExtends)
 {
     string infoPath = m_obFinder.getClassPath(obExtends.Name.Replace(".as", ""));
     if (File.Exists(infoPath))
     {
         XmlDocument xml = new XmlDocument();
         xml.Load(infoPath);
         XmlNodeReader reader = new XmlNodeReader(xml);
         while (reader.Read())
         {
             if (reader.NodeType == XmlNodeType.Element)
             {
                 if (reader.Name == "item")
                 {
                     string className = reader.GetAttribute("name");
                     string superSign = reader.GetAttribute("super");
                     if (className == obFile.Name.Replace(".as", ""))
                     {
                         if (superSign != null)
                         {
                             reader.Close();
                             //ErrorBox.Show(obExtends.Name + " extends " + obFile.Name,"ClassRelationsFinderError");
                             return true;
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
コード例 #2
0
        /*
         * get appx unique flag from Manifest file
         * not completed
        */
        public string GetAppxSignature(string appx)
        {
            string xmlFilePath = this.srcPath + appx + @"\AppxManifest.xml";
            XmlDocument xmldoc = new XmlDocument();
            XmlNodeReader reader = null;

            //string appId = null;
            string platform = null;
            string publisher = null;
            string version = null;
            string name = null;

            try
            {
                xmldoc.Load(xmlFilePath);
                XmlElement root = xmldoc.DocumentElement;
                root = xmldoc.DocumentElement;

                // using Node Reader
                reader = new XmlNodeReader(xmldoc);
                while (reader.Read())
                {
                    if (reader.NodeType.Equals(XmlNodeType.Element)
                        && reader.Name.Equals("Identity"))
                    {
                        platform = reader.GetAttribute("ProcessorArchitecture");
                        publisher = reader.GetAttribute("Publisher");
                        version = reader.GetAttribute("Version");
                        name = reader.GetAttribute("Name");
                        break;
                    }
                    //if (reader.NodeType.Equals(XmlNodeType.Element)
                    //    && reader.Name.Equals("Application"))
                    //{
                    //    appId = reader.GetAttribute("Id");
                    //}
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                if (null != reader)
                {
                    reader.Close();
                }
            }

            return string.Join("<br>", platform, publisher, version, name);
        }
コード例 #3
0
ファイル: XmlHelper.cs プロジェクト: qinfengwangyi/Qin.Blog
        /// <summary>
        /// 获取XML
        /// </summary>
        /// <param name="xmlFile"></param>
        /// <returns></returns>
        // xmlFile = HttpContext.Server.MapPath("~/Student.xml")
        public string GetXml(string xmlFile)
        {
            string id = "";
            string Info = "";

            if (XmlDoc == null)
            {
                lock (DocLock)
                {
                    if (XmlDoc == null)
                    {
                        XmlDoc = new XmlDocument();
                        XmlDoc.Load(xmlFile);
                    }
                }
            }

            string Name = string.Empty;
            string _id = string.Empty;
            XmlElement root = XmlDoc.DocumentElement;
            XmlNodeList personNodes = root.GetElementsByTagName("person");
            foreach (XmlNode node in personNodes)
            {
                if (((XmlElement)node).GetAttribute("id") == "2" || ((XmlElement)node).GetAttribute("id") == "4")
                {
                    Name += ((XmlElement)node).InnerText;
                    _id += ((XmlElement)node).GetAttribute("id");
                    var str = node.GetEnumerator();
                }
            }

            XmlNodeReader ParaReader = new XmlNodeReader(XmlDoc);
            while (ParaReader.Read())
            {
                if (ParaReader.NodeType == XmlNodeType.Element && ParaReader.Name == "person")
                {
                    if (!string.IsNullOrEmpty(ParaReader.GetAttribute("id")))
                    {
                        id += ParaReader.GetAttribute("id") + "+";
                        Info += ParaReader.ReadInnerXml() + "+";

                    }
                    //if (f == "PaymentDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute(1);//Info = ParaReader.GetAttribute(1).Replace("{2}", Member.ValidBeginDate + "");//缴费
                    //if (f == "ReplacementDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute("value");//Info = ParaReader.GetAttribute("value").Replace("{2}", Member.ValidBeginDate + "").Replace("{3}", Member.ReplacementDate + "");  //换证 
                    //if (f == "ContributionsDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute("value"); //体检 
                }
                string str = ParaReader.GetAttribute("id") + ParaReader.GetAttribute("sex") + ParaReader.ReadInnerXml();
            }
            ParaReader.Close();
            return System.Text.Encoding.GetEncoding("gb2312").GetString(System.Text.Encoding.Default.GetBytes(id + "\n" + Info));
        }
コード例 #4
0
ファイル: ValidateXMLFile.cs プロジェクト: neilmayhew/pathway
        public bool ValidateNodeAttribute()
        {
            string propertyValue;
            XmlNodeReader reader;
            bool match = true;

            XmlNode node = Common.GetXmlNode(FileNameWithPath, XPath);

            if (node == null)
            {
                match = false;
            }
            else
            {
                foreach (string propertyKey in ClassProperty.Keys)
                {
                    reader = new XmlNodeReader(node);
                    reader.Read();
                    propertyValue = reader.GetAttribute(propertyKey);
                    if (propertyValue != null && propertyValue != ClassProperty[propertyKey])
                    {
                        match = false;
                    }
                }
            }
            reader = null;
            ClassProperty.Clear();
            return match;
        }
コード例 #5
0
        private static void read_browse(bool browse, XmlNodeReader nodeReader, Item_Aggregation hierarchyObject )
        {
            // Create a new browse/info object
            Item_Aggregation_Browse_Info newBrowse = new Item_Aggregation_Browse_Info
                                {
                                    Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_Home,
                                    Source = Item_Aggregation_Browse_Info.Source_Type.Static_HTML,
                                    Data_Type = Item_Aggregation_Browse_Info.Result_Data_Type.Text
                                };

            bool isDefault = false;

            string code = String.Empty;

            // Determine which XML node name to look for and set browse v. info
            string lastName = "HI:BROWSE";
            if (!browse)
            {
                lastName = "HI:INFO";
                newBrowse.Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Info;
            }

            // Check for the attributes
            if (nodeReader.HasAttributes)
            {
                if (nodeReader.MoveToAttribute("location"))
                {
                    if (nodeReader.Value == "BROWSEBY")
                        newBrowse.Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_By;
                }
                if (nodeReader.MoveToAttribute("default"))
                {
                    if (nodeReader.Value == "DEFAULT")
                        isDefault = true;
                }
            }

            // Step through the XML and build this browse/info object
            while (nodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (nodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = nodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                        case "HI:METADATA":
                            nodeReader.Read();
                            newBrowse.Code = nodeReader.Value.ToLower();
                            newBrowse.Source = Item_Aggregation_Browse_Info.Source_Type.Database;
                            newBrowse.Data_Type = Item_Aggregation_Browse_Info.Result_Data_Type.Table;
                            break;

                        case "HI:CODE":
                            nodeReader.Read();
                            newBrowse.Code = nodeReader.Value.ToLower();
                            break;

                        case "HI:TITLE":
                            // Look for a language attached to this title
                            string titleLanguage = String.Empty;
                            if ((nodeReader.HasAttributes) && ( nodeReader.MoveToAttribute("lang")))
                            {
                                titleLanguage = nodeReader.GetAttribute("lang");
                            }

                            // read and save the title
                            nodeReader.Read();
                            newBrowse.Add_Label( nodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(titleLanguage));
                            break;

                        case "HI:BODY":
                            // Look for a language attached to this title
                            string bodyLanguage = String.Empty;
                            if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang")))
                            {
                                bodyLanguage = nodeReader.GetAttribute("lang");
                            }

                            // read and save the title
                            nodeReader.Read();
                            string bodySource = nodeReader.Value;
                            newBrowse.Add_Static_HTML_Source(bodySource, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage));
                            break;
                    }
                }

                if (nodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (nodeReader.Name.Trim().ToUpper() == lastName )
                    {
                        hierarchyObject.Add_Browse_Info(newBrowse);

                        // If this set the default browse by save that information
                        if ((newBrowse.Browse_Type == Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_By) && (isDefault))
                        {
                            hierarchyObject.Default_BrowseBy = newBrowse.Code;
                        }

                        return;
                    }
                }
            }
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: xpoi5010/TimeTable
        //Add:1.0.1.0
        public EventInfo[] LoadXML(string path)
        {
            System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
            SavePath = path;
            xd.Load(SavePath);
            System.Xml.XmlNodeReader xnr = new System.Xml.XmlNodeReader(xd);
            string           Time        = "";
            string           element     = "";
            bool             IsEvent     = false;
            EventInfo        temp        = new EventInfo();
            string           start       = "";
            string           week        = "";
            List <EventInfo> output      = new List <EventInfo>();

            while (xnr.Read())
            {
                switch (xnr.NodeType)
                {
                case (XmlNodeType.Element):
                    element = xnr.Name;
                    switch (element)
                    {
                    case ("Timetable"):
                        start = xnr.GetAttribute("start");
                        string[] split = System.Text.RegularExpressions.Regex.Split(start, ",");
                        dateSelecter1.Year  = Convert.ToInt32(split[0]);
                        dateSelecter1.Month = Convert.ToInt32(split[1]);
                        dateSelecter1.Day   = Convert.ToInt32(split[2]);
                        break;

                    case ("Event"):
                        IsEvent = true;
                        week    = "";
                        start   = "";
                        temp    = new EventInfo();
                        break;

                    case ("Time"):
                        Time = xnr.GetAttribute("time");
                        break;

                    case ("Repeat"):
                        week = xnr.GetAttribute("week");

                        break;
                    }
                    break;

                case (XmlNodeType.Text):
                    if (IsEvent)
                    {
                        if (element == "Name")
                        {
                            temp.starttime = new Time(Time);
                            temp.EventName = xnr.Value;
                        }
                        else if (element == "Repeat")
                        {
                            string[] Split = System.Text.RegularExpressions.Regex.Split(xnr.Value, ":");
                            int[]    w_    = Array.ConvertAll(Split, item => Convert.ToInt32(item));
                            if (week == "" || week == null)
                            {
                                temp.Repeat_OneWeek  = w_;
                                temp.Repeat_Biweekly = temp.Repeat_OneWeek;
                            }
                            if (week == "1")
                            {
                                temp.Repeat_OneWeek = w_;
                            }
                            if (week == "2")
                            {
                                temp.Repeat_Biweekly = w_;
                            }
                        }
                    }
                    break;

                case (XmlNodeType.EndElement):
                    switch (xnr.Name)
                    {
                    case ("Event"):
                        IsEvent = false;
                        output.Add(temp);
                        temp = new EventInfo();
                        break;
                    }
                    break;
                }
            }
            xnr.Close();
            return(output.ToArray());
        }
コード例 #7
0
 //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡη�����ȡ����
 private void readScheme(string name)
 {
     ArrayList m_arrDataCollect = new ArrayList();
     XmlDocument xml = new XmlDocument();
     xml.Load(name);
     XmlNodeReader reader = new XmlNodeReader(xml);
     while (reader.Read())
     {
         switch (reader.NodeType)
         {
             case XmlNodeType.Element:
                 switch (reader.Name)
                 {
                     case "baseInfo":
                         m_nLetterDigit = int.Parse(reader.GetAttribute("length"));
                         m_nSafeCount = int.Parse(reader.GetAttribute("safeCount"));
                         break;
                     case "item":
                         string used = reader.GetAttribute("used");
                         bool blUsed = false;
                         if (used != null)
                         {
                             blUsed = (bool)used.Equals("true", StringComparison.OrdinalIgnoreCase);
                         }
                         if (blUsed)
                         {
                             m_arrDataCollect.Add(reader.GetAttribute("data"));
                         }
                         break;
                     case "exClude":
                         m_arrExclude.Add(reader.GetAttribute("name"));
                         break;
                 }
                 break;
         }
     }
     if (reader != null)
     {
         reader.Close();
     }
     for (int i = 0; i < m_arrDataCollect.Count; i++)
     {
         string data = m_arrDataCollect[i].ToString();
         for (int j = 0; j < data.Length; j++)
         {
             m_arrData.Add(data[j].ToString());
         }
     }
 }
コード例 #8
0
ファイル: RenderUtil.cs プロジェクト: harpreetoxyent/pnl
 public static void mergeChildNodes(XmlDocument nolisExtDoc, XmlNode extNode, XmlNode rootNode, String uniqueIdAttribute)
 {
     IList itemList = new ArrayList();
     foreach (XmlNode itemNode in rootNode.ChildNodes)
     {
         if (itemNode.NodeType == XmlNodeType.Element)
         {
             XmlNodeReader reader = new XmlNodeReader(itemNode);
             reader.Read();
             String idAttributeValue = reader.GetAttribute(uniqueIdAttribute);
             //Console.WriteLine("idAttributeValue = " + idAttributeValue);
             reader.Close();
             Boolean isIdExist = false;
             foreach (XmlNode extItemNode in extNode.ChildNodes)
             {
                 if (extItemNode.NodeType == XmlNodeType.Element)
                 {
                     XmlNodeReader localReader = new XmlNodeReader(extItemNode);
                     localReader.Read();
                     String extIdAttributeValue = localReader.GetAttribute(uniqueIdAttribute);
                     Console.WriteLine("extIdAttributeValue = " + extIdAttributeValue);
                     localReader.Close();
                     if (extIdAttributeValue.Equals(idAttributeValue))
                     {
                         isIdExist = true;
                         break;
                     }
                 }
             }
             if (isIdExist)
             {
                 continue;
             }
             else
             {
                 itemList.Add(itemNode);
             }
         }
     }
     Console.WriteLine("size of itemList  = " + itemList.Count);
     foreach (Object objXmlNode in itemList)
     {
         XmlNode newNode = nolisExtDoc.ImportNode((XmlNode)objXmlNode, true);
         extNode.AppendChild(newNode);
     }
 }
コード例 #9
0
        /// <summary>
        /// Removing this from the IXmlSerializable Implementation because engineers keep exposing the SerialzableDictionary object
        /// and that cannot be allowed because nobody else can deserialize.  It is for persistance only so the logic was moved here.
        /// </summary>
        /// <param name="doc">The doc.</param>
        /// <returns></returns>
        private IList<string> convertFromXml(XmlDocument doc)
        {
            XmlReader reader = new XmlNodeReader(doc);

            //First check empty element and return if found
            bool wasEmpty = reader.IsEmptyElement;
            reader.Read();
            if (wasEmpty)
                return null;

            IList<string> result = new List<string>();
            reader.ReadStartElement(DocumentElement);

            if (reader.NodeType != XmlNodeType.Element)
                return result;

            //Loop through the nodes representing this object in the reader
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                //First try the optimized format
                //string key = reader.GetAttribute(KEY_ATTRIBUTE);
                string typeName = reader.GetAttribute(TYPE_ATTRIBUTE);

                //Read the Xml element representing a new key & value pair
                reader.ReadStartElement(ITEM_ELEMENT);

                //if (String.IsNullOrEmpty(key))
                //{
                //    //Key is not being stoed as an attribute - this must be xml in the old format
                //    //KEEP THIS CODE FOR BACKWARDS COMPATIBILITY

                //    //First we need to get the type of the object written to the Xml during serialization so that
                //    //we can create a new serializer that understands how to deserialize this type.
                //    typeName = reader.GetAttribute(TYPE_ATTRIBUTE);

                //    //Read the Xml element representing the key in this key & value pair
                //    reader.ReadStartElement(KEY_ELEMENT);

                //    //Allright now create the serializer and deserialize the defined object type
                //    XmlSerializer keySerializer = new XmlSerializer(typeof(string));
                //    //key = (string)keySerializer.Deserialize(reader);

                //    if (key == null)
                //        throw new ApplicationException(String.Format("Null key encountered on line {0}",
                //                                                       reader.Depth));

                //    //Read the end of the key element
                //    reader.ReadEndElement();
                //}

                Type valuetype = (typeName != null ? Type.GetType(typeName) : typeof(object)) ?? typeof(object);

                //Read the Xml element representing the value in this key & value pair
                reader.ReadStartElement(VALUE_ELEMENT);

                //Now create the serialize and deserialize the object type defined from the type attribute
                XmlSerializer valueSerializer = new XmlSerializer(valuetype);

                //HACK!!!
                //Make sure you catch any errors caused by invalid types cannot be deserialized. For example this whole process
                //kept blowing up because the type ould not be serialized.
                string value;// = (TValue) valueSerializer.Deserialize(reader);
                try { value = (string)valueSerializer.Deserialize(reader); }
                catch (Exception)
                {
                    value = default(string);
                    //skip top the end of the current element
                    reader.Skip();
                }

                //Read the end of the value element
                reader.ReadEndElement();

                //Now add the deserialized objects to the hashtable.
                result.Add(value);

                //Read the end of the element holding the key and value elements
                if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == ITEM_ELEMENT)
                    reader.ReadEndElement();
                reader.MoveToContent();
            }

            //All done - read the ending element
            reader.ReadEndElement();

            return result;
        }
コード例 #10
0
 //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ��б��������
 public static string[] getIncludeList(ArrayList obList, ArrayList fileList, FileInfo obInfo, ClassFinder obFinder, ClassInfoFinder infoFinder)
 {
     if (File.Exists(obInfo.FullName))
     {
         XmlDocument xml = new XmlDocument();
         xml.Load(obInfo.FullName);
         XmlNodeReader reader = new XmlNodeReader(xml);
         while (reader.Read())
         {
             if (reader.NodeType == XmlNodeType.Element)
             {
                 if (reader.Name == "item")
                 {
                     string className = reader.GetAttribute("name");
                     string SkinClass_sign = reader.GetAttribute("skin");
                     if (SkinClass_sign == null)
                     {
                         string classPath = obFinder.getClassPath(className);
                         if (!File.Exists(classPath))
                             ErrorBox.Show(className + " cont find ", "ClassNameFinderError");
                         string infoPath = infoFinder.getClassPath(className);
                         if (File.Exists(infoPath))
                         {
                             if (fileList.IndexOf(infoPath) < 0)
                             {
                                 fileList.Add(infoPath);
                                 FileInfo subInfo = new FileInfo(infoPath);
                                 getIncludeList(obList, fileList, subInfo, obFinder, infoFinder);
                             }
                         }
                         else
                         {
                             ErrorBox.Show("className:" + className + "\r\nfileMissed:" + infoPath, "ClassNameFinderError");
                         }
                         ClassRelationsFinder ClassRelation = new ClassRelationsFinder(infoFinder);
                         for (int i = 0; i < obList.Count; i++)
                         {
                             if (obList.IndexOf(classPath) < 0)
                             {
                                 string testClass = obList[i] as string;
                                 FileInfo obTest = new FileInfo(testClass);
                                 FileInfo obFile = new FileInfo(classPath);
                                 if (ClassRelation.isSuper(obFile, obTest))
                                 {
                                     obList.Insert(i, classPath);
                                     break;
                                 }
                                 //else if (ClassRelation.isSuper(obTest, obFile))
                                 //{
                                 //    obList.Insert(i + 1, classPath);
                                 //    break;
                                 //}
                             }
                         }
                         if (obList.IndexOf(classPath) < 0)
                             obList.Add(classPath);
                     }
                     //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ���Դ�жϺ���
                 }
             }
             //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡνڵ��жϺ���
         }
     }
     return obList.ToArray(typeof(string)) as string[];
 }
コード例 #11
0
        private static void read_settings(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject)
        {
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                        case "HI:WEBSKINS":
                            NodeReader.Read();
                            string webskins = NodeReader.Value;
                            string[] splitter = webskins.Split(",".ToCharArray());
                            foreach (string thisSplitter in splitter)
                            {
                                if ( thisSplitter.Length > 0 )
                                    HierarchyObject.Add_Web_Skin(thisSplitter.ToLower());
                            }
                            break;

                        case "HI:CSS":
                            NodeReader.Read();
                            HierarchyObject.CSS_File = NodeReader.Value.Trim();
                            break;

                        case "HI:CUSTOMHOME":
                            NodeReader.Read();
                            // No longer do anything with this tag
                            // HierarchyObject.Custom_Home_Page_Source_File = NodeReader.Value.Trim();
                            break;

                        case "HI:FACETS":
                            NodeReader.Read();
                            string facets = NodeReader.Value;
                            string[] splitter2 = facets.Split(",".ToCharArray());
                            HierarchyObject.Clear_Facets();
                            foreach (string thisSplitter2 in splitter2)
                            {
                                    HierarchyObject.Add_Facet(Convert.ToInt16(thisSplitter2));
                            }
                            break;

                        case "HI:MAPSEARCH":
                            if (NodeReader.MoveToAttribute("type"))
                            {
                                switch (NodeReader.GetAttribute("type").ToLower())
                                {
                                    case "extent":
                                    case "computed":
                                        // This should already be set, assuming there were values to be added
                                        if (HierarchyObject.Map_Search_Display == null)
                                        {
                                            HierarchyObject.Map_Search_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.COMPUTED);
                                        }
                                        break;

                                    case "fixed":
                                        decimal latitude = 999;
                                        decimal longitude = 999;
                                        int zoom = 999;

                                        if (NodeReader.MoveToAttribute("latitude"))
                                        {
                                            Decimal.TryParse(NodeReader.GetAttribute("latitude"), out latitude);
                                        }
                                        if (NodeReader.MoveToAttribute("longitude"))
                                        {
                                            Decimal.TryParse(NodeReader.GetAttribute("longitude"), out longitude);
                                        }
                                        if (NodeReader.MoveToAttribute("zoom"))
                                        {
                                            Int32.TryParse(NodeReader.GetAttribute("zoom"), out zoom);
                                        }

                                        if ((latitude != 999) && (longitude != 999))
                                        {
                                            HierarchyObject.Map_Search_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.FIXED, zoom, longitude, latitude );
                                        }
                                        break;
                                }
                            }
                            break;

                        case "HI:MAPBROWSE":
                            if (NodeReader.MoveToAttribute("type"))
                            {
                                switch (NodeReader.GetAttribute("type").ToLower())
                                {
                                    case "extent":
                                        HierarchyObject.Map_Browse_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.EXTENT);
                                        break;

                                    case "computed":
                                        HierarchyObject.Map_Browse_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.COMPUTED);
                                        break;

                                    case "fixed":
                                        decimal latitude = 999;
                                        decimal longitude = 999;
                                        int zoom = 999;

                                        if (NodeReader.MoveToAttribute("latitude"))
                                        {
                                            Decimal.TryParse(NodeReader.GetAttribute("latitude"), out latitude);
                                        }
                                        if (NodeReader.MoveToAttribute("longitude"))
                                        {
                                            Decimal.TryParse(NodeReader.GetAttribute("longitude"), out longitude);
                                        }
                                        if (NodeReader.MoveToAttribute("zoom"))
                                        {
                                            Int32.TryParse(NodeReader.GetAttribute("zoom"), out zoom);
                                        }

                                        if ((latitude != 999) && (longitude != 999))
                                        {
                                            HierarchyObject.Map_Browse_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.FIXED, zoom, longitude, latitude);
                                        }
                                        break;
                                }
                            }
                            break;

                    }
                }

                if (NodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (NodeReader.Name.Trim().ToUpper() == "HI:SETTINGS")
                    {
                        return;
                    }
                }
            }
        }
コード例 #12
0
ファイル: ChatSender.cs プロジェクト: r1ng0to3tour/swsplayer
 //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡνڵ��ȡ����
 private static ArrayList getList(XmlNode subX)
 {
     ArrayList arr = new ArrayList();
     XmlNodeReader reader = new XmlNodeReader(subX);
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             ArrayList subArr = null;
             if (reader.Name == "item")
             {
                 subArr = new ArrayList();
                 string stName = reader.GetAttribute("name");
                 subArr.Add(stName);
                 arr.Add(subArr);
             }
             if (reader.Name == "str")
             {
                 subArr = arr[arr.Count - 1] as ArrayList;
                 string stName = reader.GetAttribute("name");
                 subArr.Add(stName);
             }
             if (reader.Name == "chat")
             {
                 subArr = arr[arr.Count - 1] as ArrayList;
                 string stName = reader.GetAttribute("name");
                 string stPrefix = reader.GetAttribute("prefix");
                 ArrayList arrLink = new ArrayList();
                 arrLink.Add(stPrefix);
                 arrLink.Add(stName);
                 subArr.Add(arrLink);
             }
         }
     }
     reader.Close();
     return arr;
 }
コード例 #13
0
        public ReadFromXml(string instr)
        {
            string sOID = ""; //start object id
            string sPID = ""; //start point id
            string eOID = ""; //end object id
            string ePID = ""; //end point id

            cdList = new ArrayList();
            cnList = new ArrayList();
            ccList = new ArrayList();

            Node a = new Node("123","789"); //dummy
            cnList.Add(a);

            //Create XML DOM instance
            XmlDocument document = new XmlDocument();
            document.LoadXml(instr);
            //Select all graphic object elements and connections
            XmlNodeList objList1 = document.SelectNodes("//graphicObject");
            XmlNodeList objList2 = document.SelectNodes("//connection");

            int countDevice=0;

            int countResistor=1;
            int countCapacitor=1;
            int countInductor=1;
            int countTransitor=1;
            int countVDC=1;
            int countVAC=1;
            int countCsource=1;
            int countGround =1;
            int countJFET =1;
            int countOpamp=1;
            int countDiode=1;

            foreach(XmlNode objNode in objList1)
            {
                XmlNodeReader objNodeReader = new XmlNodeReader(objNode);

                while(objNodeReader.Read())	//read thru all child nodes of this node
                {
                    if(objNodeReader.NodeType == XmlNodeType.Element)	//	***READING NODES AND DEVICE***
                    {
                        if(objNodeReader.Name == "graphicObject")
                        {
                            objID = objNodeReader.GetAttribute("id");	// to read the id attribute of the element
                            template = objNodeReader.GetAttribute("template");	// to read the template attribute of the element, test if it is Capacitor, Resistor or others
                            type = objNodeReader.GetAttribute("type");	// to read the type attribute of the element, test if it is a link node.

                            switch ( template )	// typecast to specific type of device.
                            {
                                case "Resistor" :
                                    device = (Resistor)new Resistor(objID, "" + countDevice);    //chester
                                    countDevice++;
                                    countResistor++;
                                    break;

                                case "VsourceDC" :
                                    device = (VsourceDC)new VsourceDC(objID, ""+countDevice);       //chester
                                    countDevice++;
                                    countVDC++;
                                    break;

                                case "Inductor" :
                                    //device = (Inductor) new Inductor(objID,""+countDevice);
                                    device = (Inductor) new Inductor(objID,""+countInductor);
                                    countInductor++;
                                    //countDevice++;
                                    break;
                                case "Capacitor" :
                                    //device = (Capacitor) new Capacitor(objID,""+countDevice);
                                    device = (Capacitor)new Capacitor(objID, "" + countCapacitor);
                                    countCapacitor++;
                                    //countDevice++;
                                    break;
                                case "VsourceAC" :
                                    //device = (VsourceAC) new VsourceAC(objID,""+countDevice);
                                    device = (VsourceAC) new VsourceAC(objID,""+countVAC);
                                    countVAC++;
                                    //countDevice++;
                                    break;
                                case "Csource" :
                                    //device = (Csource) new Csource(objID,""+countDevice);
                                    device = (Csource) new Csource(objID,""+countCsource);
                                    countCsource++;
                                    break;
                                case "Diode" :
                                    device = (Diode) new Diode(objID,""+countDiode);
                                    countDiode++;
                                    break;
                                case "Transitor" :
                                    //device = (Transitor) new Transitor(objID,""+countDevice);
                                    device = (Transitor)new Transitor(objID, "" + countTransitor);
                                    countTransitor++;
                                    //countDevice++;
                                    break;
                                case "Ground" :
                                    device = (Ground) new Ground(objID,""+countGround);
                                    countGround++;
                                    break;
                                case "JFET" :
                                    device = (JFET) new JFET(objID,""+countJFET);
                                    countJFET++;
                                    break;

                                case "Opamp" :
                                    device = (Opamp) new Opamp(objID,""+countOpamp);
                                    countOpamp++;
                                    break;
                                default:
                                    device = new Device();
                                    device.SetID(objID);
                                    break;
                            }

                            #region "Chester for new device implementation"
                                 device.convert(objNodeReader);
                            #endregion

                            if (!cdList.Contains(device))
                            {
                                cdList.Add(device);
                            }

                        }
                    }
                }
            }

            //reading connection
            int countNode=0;
            IEnumerator cnEnum;

            foreach(XmlNode objNode in objList2)
            {
                XmlNodeReader objNodeReader = new XmlNodeReader(objNode);
                Node startNode = new Node();
                Node endNode = new Node();

                int cnt=0;

                while(objNodeReader.Read())	//read thru all child nodes of this node
                {
                    if(objNodeReader.NodeType == XmlNodeType.Element)
                    {

                        //Console.WriteLine(cnList.Count);
                        if(objNodeReader.Name == "point" && cnt%2==0 )
                        {
                            sOID = objNodeReader.GetAttribute("objectID");
                            sPID = objNodeReader.GetAttribute("pointID");

                            startNode.SetObjID(sOID);
                            startNode.SetPtID(sPID);
                            startNode.setstart(true);
                            cnEnum = cnList.GetEnumerator();

                            int countAll1=1;
                            while(cnEnum.MoveNext())
                            {
                                string currentObjID = ((Node)cnEnum.Current).GetObjID();
                                string currentPtID = ((Node)cnEnum.Current).GetPtID();
                                if(sOID!=null && sPID!=null)
                                {
                                    if(currentObjID.Equals(sOID) && currentPtID.Equals(sPID))
                                    {
                                        startNode.SetName(((Node)cnEnum.Current).GetName());
                                        break;
                                    }
                                    else
                                    {
                                        if(cnList.Count==countAll1)
                                        {
                                            //string name = "N"+countNode;
                                            string name = countNode+"";
                                            startNode.SetName(name);
                                            countNode++;
                                            cnList.Add(startNode);
                                            countAll1++;
                                            break;
                                        }

                                    }
                                }
                                countAll1++;
                                //Console.WriteLine("cnList count "+cnList.Count+" count 1 " + countAll1 );

                            }

                            cnt++;
                        }
                        else if(objNodeReader.Name == "point")
                        {
                            eOID = objNodeReader.GetAttribute("objectID");
                            ePID = objNodeReader.GetAttribute("pointID");
                            endNode.SetObjID(eOID);
                            endNode.SetPtID(ePID);
                            cnEnum = cnList.GetEnumerator();

                            int countAll2=1;
                            while(cnEnum.MoveNext())
                            {
                                string currentObjID = ((Node)cnEnum.Current).GetObjID();
                                string currentPtID = ((Node)cnEnum.Current).GetPtID();
                                if(eOID!=null && ePID!=null)
                                {
                                    if(currentObjID.Equals(eOID) && currentPtID.Equals(ePID))
                                    {
                                        endNode.SetName(((Node)cnEnum.Current).GetName());
                                        break;
                                    }
                                    else
                                    {
                                        if(cnList.Count==countAll2)
                                        {
                                            //string name = "N"+countNode;
                                            string name = ""+countNode;
                                            endNode.SetName(name);
                                            countNode++;
                                            cnList.Add(endNode);

                                            countAll2++;
                                            break;

                                        }
                                    }

                                }
                                countAll2++;
                                //Console.WriteLine(cnList.Count+" count 2 " + countAll2 );
                            }
                            if(eOID!=null && ePID!=null)
                            {
                                Connection connection = new Connection(startNode,endNode);
                                ccList.Add(connection);
                                startNode = new Node();
                                endNode = new Node();
                            }
                            cnt=0;

                        }

                    }
                }
            }
            cnList.RemoveAt(0);
            cnList.TrimToSize();

            IEnumerator cEnum = ccList.GetEnumerator();
            IEnumerator dEnum = cdList.GetEnumerator();
            IEnumerator nEnum = cnList.GetEnumerator();

            //to set the device name of the node
            while(nEnum.MoveNext())
            {
                dEnum = cdList.GetEnumerator();
                while(dEnum.MoveNext())
                {
                    if(((Node)nEnum.Current).GetObjID().Equals(((Device)dEnum.Current).GetID()))
                    {
                        ((Node)nEnum.Current).SetDeviceName(((Device)dEnum.Current).GetName());

                        if(((Device)dEnum.Current).GetNodeCount() == 0)
                        {
                            ((Device)dEnum.Current).SetNode1((Node)nEnum.Current);
                        }
                        else if(((Device)dEnum.Current).GetNodeCount() == 1)
                        {
                            ((Device)dEnum.Current).SetNode2((Node)nEnum.Current);
                        }
                        else if(((Device)dEnum.Current).GetNodeCount() == 2)
                        {
                            ((Device)dEnum.Current).SetNode3((Node)nEnum.Current);
                        }

                    }

                }
            }
            cEnum = ccList.GetEnumerator();
            dEnum = cdList.GetEnumerator();
            nEnum = cnList.GetEnumerator();
            //to set nodes in to the device
        }
コード例 #14
0
        private static void read_browse(bool Browse, XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject)
        {
            // Create a new browse/info object
            Complete_Item_Aggregation_Child_Page newBrowse = new Complete_Item_Aggregation_Child_Page
                                {
                                    Browse_Type = Item_Aggregation_Child_Visibility_Enum.Main_Menu,
                                    Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Static_HTML
                                };

            bool isDefault = false;

            // Determine which XML node name to look for and set browse v. info
            string lastName = "HI:BROWSE";
            if (!Browse)
            {
                lastName = "HI:INFO";
                newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None;
            }

            // Check for the attributes
            if (NodeReader.HasAttributes)
            {
                if (NodeReader.MoveToAttribute("location"))
                {
                    if (NodeReader.Value == "BROWSEBY")
                        newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By;
                }
                if (NodeReader.MoveToAttribute("default"))
                {
                    if (NodeReader.Value == "DEFAULT")
                        isDefault = true;
                }
                if (NodeReader.MoveToAttribute("visibility"))
                {
                    switch (NodeReader.Value)
                    {
                        case "NONE":
                            newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None;
                            break;

                        case "MAIN_MENU":
                            newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Main_Menu;
                            break;

                        case "BROWSEBY":
                            newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By;
                            break;
                    }
                }
                if (NodeReader.MoveToAttribute("parent"))
                {
                    newBrowse.Parent_Code = NodeReader.Value;
                }
            }

            // Step through the XML and build this browse/info object
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                        case "HI:METADATA":
                            NodeReader.Read();
                            newBrowse.Code = NodeReader.Value.ToLower();
                            newBrowse.Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Database_Table;
                            break;

                        case "HI:CODE":
                            NodeReader.Read();
                            newBrowse.Code = NodeReader.Value.ToLower();
                            break;

                        case "HI:TITLE":
                            // Look for a language attached to this title
                            string titleLanguage = String.Empty;
                            if ((NodeReader.HasAttributes) && ( NodeReader.MoveToAttribute("lang")))
                            {
                                titleLanguage = NodeReader.GetAttribute("lang");
                            }

                            // read and save the title
                            NodeReader.Read();
                            newBrowse.Add_Label( NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(titleLanguage));
                            break;

                        case "HI:BODY":
                            // Look for a language attached to this title
                            string bodyLanguage = String.Empty;
                            if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                            {
                                bodyLanguage = NodeReader.GetAttribute("lang");
                            }

                            // read and save the title
                            NodeReader.Read();
                            string bodySource = NodeReader.Value;
                            newBrowse.Add_Static_HTML_Source(bodySource, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage));
                            break;
                    }
                }

                if (NodeReader.NodeType == XmlNodeType.EndElement)
                {
                    if (NodeReader.Name.Trim().ToUpper() == lastName )
                    {
                        // Don't add ALL or NEW here
                        if ((String.Compare(newBrowse.Code, "all", StringComparison.InvariantCultureIgnoreCase) != 0) && (String.Compare(newBrowse.Code, "new", StringComparison.InvariantCultureIgnoreCase) != 0))
                        {
                            HierarchyObject.Add_Child_Page(newBrowse);
                            //HierarchyObject.Add

                            // If this set the default browse by save that information
                            if ((newBrowse.Browse_Type == Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By) && (isDefault))
                            {
                                HierarchyObject.Default_BrowseBy = newBrowse.Code;
                            }
                        }

                        return;
                    }
                }
            }
        }
コード例 #15
0
ファイル: DiskMap.cs プロジェクト: r1ng0to3tour/swsplayer
 //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡζ˿ڶ�ȡ����
 private static void readMapList()
 {
     XmlDocument xml = new XmlDocument();
     string filePath = RootConfig.DriverMapConfig;
     if (m_arrDriver == null)
     {
         m_arrDriver = new ArrayList();
         m_arrFolder = new ArrayList();
         m_arrLabel = new ArrayList();
     }
     if (File.Exists(filePath))
     {
         FileStream fs = new FileStream(filePath, FileMode.Open);
         try
         {
             xml.Load(fs);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
         XmlNode subXml = HxmlReader.getData(xml);
         if (subXml != null)
         {
             XmlNodeReader reader = new XmlNodeReader(subXml);
             while (reader.Read())
             {
                 if (reader.NodeType == XmlNodeType.Element)
                 {
                     if (reader.Name == "item")
                     {
                         string stDriverName = reader.GetAttribute("name");
                         string stPath = reader.GetAttribute("path");
                         string stLabel = reader.GetAttribute("label");
                         DirectoryInfo di = new DirectoryInfo(stPath);
                         if (stDriverName != null && di.Exists)
                         {
                             m_arrDriver.Add(stDriverName.ToUpper());
                             m_arrFolder.Add(stPath);
                             m_arrLabel.Add(stLabel);
                         }
                     }
                 }
             }
             fs.Close();
         }
     }
 }
コード例 #16
0
        public static string getKeyValueFromXmlConfigFile(string configFileName, string xmlNodeName, string key)
        {
            string attribute;
            try
            {
                configFileName = GetFileSystemResourceWithoutProtocol(configFileName);
                XmlDocument document = null;
                if (_configFileHashTable != null)
                {
                    document = (XmlDocument) _configFileHashTable[configFileName];
                }
                if ((document == null) || (_configFileHashTable == null))
                {
                    lock (typeof(Hashtable))
                    {
                        if ((document == null) || (_configFileHashTable == null))
                        {
                            LoadAndCacheXmlConfigFile(configFileName);
                            document = (XmlDocument) _configFileHashTable[configFileName];
                        }
                    }
                }
                XmlNodeList elementsByTagName = document.GetElementsByTagName(xmlNodeName);
                XmlNodeReader reader = null;
                attribute = null;
                foreach (XmlNode node in elementsByTagName)
                {
                    reader = new XmlNodeReader(node);
                    reader.Read();
                    attribute = reader.GetAttribute(key);
                    attribute.Trim();
                }
            }
            catch (Exception exception)
            {
                return null;
            }

            return attribute;
        }
コード例 #17
0
ファイル: Main.cs プロジェクト: chusiping/fasta
        //******************  添加智能提示的列表  ******************************
        public void Suggest()
        {
            AutoCompleteStringCollection acsc = new AutoCompleteStringCollection();
            ComboBoxItem cbi1 = new ComboBoxItem();
            string s = "";
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(AppSetting.xmlPath);
            }
            catch
            {
                if (System.IO.File.Exists(AppSetting.xmlPath))
                {
                    MessageBox.Show("消息内容", "读取文件" + AppSetting.xmlPath + "错误!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    DoXml.CreateExec();
                }

            }

            XmlNodeReader reader = new XmlNodeReader(doc);
            // 读取XML文件中的数据,并显示出来
            while (reader.Read())
            {
                //判断当前读取得节点类型
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        s = reader.Name;
                        if (s.Equals(AppSetting.keyWord))
                        {

                            cbi1.Text = reader.GetAttribute(0);
                            cbi1.Value = reader.GetAttribute(1);

                            acsc.Add(cbi1.Text);
                        }
                        break;

                }
            }
            this.comboBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
            this.comboBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
            this.comboBox1.AutoCompleteCustomSource = acsc;
        }
コード例 #18
0
ファイル: Main.cs プロジェクト: chusiping/fasta
        public void ReadXml()
        {
            string s = "";
            XmlDocument doc = new XmlDocument();

            doc.Load(AppSetting.xmlPath);

            XmlNodeReader reader = new XmlNodeReader(doc);

            while (reader.Read())
            {

                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        s = reader.Name;
                        if (s.Equals(AppSetting.keyWord))
                        {

                            ComboBoxItem cbi1 = new ComboBoxItem();
                            cbi1.Text = reader.GetAttribute(0);
                            cbi1.Value = reader.GetAttribute(1);
                            comboBox1.Items.Add(cbi1);
                        }
                        break;

                }
            }
        }
コード例 #19
0
        public static string getKeyValueFromXmlConfigResource(string resourceName, string xmlNodeName, string key)
        {
            string attribute;
            try
            {
                XmlDocument document = null;
                Assembly assembly = Assembly.GetCallingAssembly();
                string[] names = assembly.GetManifestResourceNames();
                Stream resource = assembly.GetManifestResourceStream(resourceName);

                XmlDocument configAsXmlDocument = GetConfigAsXmlDocument(resource);

                if (_configFileHashTable == null)
                {
                    _configFileHashTable = new Hashtable();
                }
                _configFileHashTable[resourceName] = configAsXmlDocument;

                document = (XmlDocument) _configFileHashTable[resourceName];
                
                XmlNodeList elementsByTagName = document.GetElementsByTagName(xmlNodeName);
                XmlNodeReader reader = null;
                attribute = null;
                foreach (XmlNode node in elementsByTagName)
                {
                    reader = new XmlNodeReader(node);
                    reader.Read();
                    attribute = reader.GetAttribute(key);
                    attribute.Trim();
                }
            }
            catch (Exception exception)
            {
                return null;
            }

            return attribute;
        }
コード例 #20
0
        private static void read_home(XmlNodeReader NodeReader, Item_Aggregation HierarchyObject)
        {
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                        case "HI:BODY":
                            if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                            {
                                string bodyLanguage = NodeReader.GetAttribute("lang");
                                NodeReader.Read();
                                HierarchyObject.Add_Home_Page_File(  NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage));
                            }
                            else
                            {
                                NodeReader.Read();
                                HierarchyObject.Add_Home_Page_File( NodeReader.Value, Web_Language_Enum.DEFAULT);
                            }

                            break;
                    }
                }

                if ((NodeReader.NodeType == XmlNodeType.EndElement) && (NodeReader.Name.Trim().ToUpper() == "HI:HOME"))
                {
                    return;
                }
            }
        }
コード例 #21
0
        private Album albumParser(XmlNodeReader reader)
        {
            string name = reader.GetAttribute("name");
            Album a = new Album(name);

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "song")
                    {
                        Song s = new Song();
                        reader.Read();
                        reader.Read();
                        s.setName(reader.Value);
                        reader.Read();
                        reader.Read();
                        reader.Read();
                        s.setLength(reader.Value);

                        a.addSong(s);
                    }
                    if (reader.Name == "reviewer")
                    {
                        Review r = new Review(reader.GetAttribute("ref"));
                        reader.Read();
                        r.setReview(reader.Value);

                        a.addReview(r);
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                    if (reader.Name == "album")
                        break;
            }

            return a;
        }
コード例 #22
0
        private static void read_home(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject)
        {
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                        case "HI:BODY":
                            Web_Language_Enum langEnum = Web_Language_Enum.DEFAULT;
                            bool isCustom = false;
                            if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang")))
                            {
                                string bodyLanguage = NodeReader.GetAttribute("lang");
                                langEnum = Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage);
                            }
                            if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("isCustom")))
                            {
                                string attribute = NodeReader.GetAttribute("isCustom");
                                if (attribute != null && attribute.ToLower() == "true")
                                    isCustom = true;
                            }

                            NodeReader.Read();
                            HierarchyObject.Add_Home_Page_File(NodeReader.Value, langEnum, isCustom );
                            break;
                    }
                }

                if ((NodeReader.NodeType == XmlNodeType.EndElement) && (NodeReader.Name.Trim().ToUpper() == "HI:HOME"))
                {
                    return;
                }
            }
        }
コード例 #23
0
        private Band bandParser(XmlNodeReader reader)
        {
            string name = reader.GetAttribute("name");
            string size = reader.GetAttribute("size");

            return new Band(name, size);
        }
コード例 #24
0
ファイル: NodeInformation.cs プロジェクト: Geor23/Planets
        static void ReadNodeInformation()
        {
            XmlNodeReader xmlNodeReader = new XmlNodeReader(xmlDocument);

            while (xmlNodeReader.Read())
            {
                if (xmlNodeReader.NodeType == XmlNodeType.Element)
                {

                    try {

                        switch (xmlNodeReader.Name)
                        {

                            case "node":
                                type = xmlNodeReader.GetAttribute("type");
                                name = xmlNodeReader.GetAttribute("name");
                                id = Convert.ToInt32(xmlNodeReader.GetAttribute("id"));

                                if (type.Equals("master"))
                                {
                                    nodes = Convert.ToInt32(xmlNodeReader.GetAttribute("nodes"));
                                }

                                break;

                            case "server":
                                serverIp = xmlNodeReader.GetAttribute("ip");
                                serverPort = Convert.ToInt32(xmlNodeReader.GetAttribute("port"));
                                break;

                            case "screen":
                                if (xmlNodeReader.GetAttribute("stereo").Equals("true"))
                                {
                                    stereo = true;
                                    eye = xmlNodeReader.GetAttribute("eye");
                                }
                                else
                                {
                                    stereo = false;
                                    eye = "stereo false";
                                }
                                break;

                            case "pa":
                                Single.TryParse(xmlNodeReader.GetAttribute("x"), out paX);
                                Single.TryParse(xmlNodeReader.GetAttribute("y"), out paY);
                                Single.TryParse(xmlNodeReader.GetAttribute("z"), out paZ);
                                break;

                            case "pb":
                                Single.TryParse(xmlNodeReader.GetAttribute("x"), out pbX);
                                Single.TryParse(xmlNodeReader.GetAttribute("y"), out pbY);
                                Single.TryParse(xmlNodeReader.GetAttribute("z"), out pbZ);
                                break;

                            case "pc":
                                Single.TryParse(xmlNodeReader.GetAttribute("x"), out pcX);
                                Single.TryParse(xmlNodeReader.GetAttribute("y"), out pcY);
                                Single.TryParse(xmlNodeReader.GetAttribute("z"), out pcZ);
                                break;

                            case "pe":
                                Single.TryParse(xmlNodeReader.GetAttribute("x"), out peX);
                                Single.TryParse(xmlNodeReader.GetAttribute("y"), out peY);
                                Single.TryParse(xmlNodeReader.GetAttribute("z"), out peZ);
                                break;
                        }

                    } catch ( Exception ex ) {
                        Debug.Log( "Configuration file <node-config> parsing error: " + ex );
                    }
                }
            }
        }
コード例 #25
0
        private Member memberParser(XmlNodeReader reader)
        {
            string name = reader.GetAttribute("name");
            string instrument = reader.GetAttribute("instrument");

            Member m = new Member(name, instrument);
            reader.Read();
            reader.Read();
            m.setJoinDate(reader.Value);

            return m;
        }
コード例 #26
0
        private Reviewer reviewerParser(XmlNodeReader reader)
        {
            Reviewer r = new Reviewer(reader.GetAttribute("id"));
            reader.Read();
            reader.Read();
            r.setName(reader.Value);
            reader.Read();
            reader.Read(); //name - end tag
            if (reader.NodeType == XmlNodeType.EndElement)
                return r;
            reader.Read();
            r.setCompany(reader.Value);

            return r;
        }
コード例 #27
0
 private void readListFile(string name)
 {
     m_obFolderList.Load(name);
     XmlNodeReader reader = new XmlNodeReader(m_obFolderList);
     while (reader.Read())
     {
         switch (reader.NodeType)
         {
             case XmlNodeType.Element:
                 switch (reader.Name)
                 {
                     case "item":
                         string folder = reader.GetAttribute("name");
                         string mixedFolder = reader.GetAttribute("mixed");
                         string mixedPackage = reader.GetAttribute("package");
                         if (folder != null)
                         {
                             m_arrFolderName.Add(folder);
                             m_arrMixedFolder.Add(mixedFolder);
                             if (mixedPackage != null)
                             {
                                 m_arrMixedPackage.Add(mixedPackage);
                             }
                         }
                         break;
                 }
                 break;
         }
     }
 }
コード例 #28
0
 //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡζ˿ڶ�ȡ����
 private void readServerConfig()
 {
     XmlDocument xml = new XmlDocument();
     string filePath = m_stHostConfig;
     if (File.Exists(filePath))
     {
         FileStream fs = new FileStream(filePath, FileMode.Open);
         try
         {
             xml.Load(fs);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
         XmlNode subXml = HxmlReader.getData(xml);
         if (subXml != null)
         {
             XmlNodeReader reader = new XmlNodeReader(subXml);
             while (reader.Read())
             {
                 if (reader.NodeType == XmlNodeType.Element)
                 {
                     if (reader.Name == "host")
                     {
                         string stName = reader.GetAttribute("name");
                         if (stName != null)
                         {
                             s_stHostName = stName;
                         }
                         string stIp = reader.GetAttribute("ip");
                         if (stIp != null)
                         {
                             s_stHostIp = stIp;
                         }
                         string stPort = reader.GetAttribute("port");
                         if (stPort != null)
                         {
                             s_nHostPort = int.Parse(stPort);
                         }
                     }
                 }
             }
             fs.Close();
         }
     }
 }
コード例 #29
0
        internal void ProcessNode(XmlNodeReader reader, DirectoryInfo targetDirectory)
        {
            StatusEventArgs e = new StatusEventArgs(this, StatusType.Parsing, 0);
            float step = 1f / _packageInstallXmlNode.ChildNodes.OfType<XmlNode>().Count();

            do
            {
                _repository.OnStatusChanged(e);
                Log.DebugFormat("ProcessNode({1}): {0}", reader.Name, ID);
                switch (reader.Name.ToLower())
                {
                    case "extract":
                        {
                            string file = VariableResolver.Expand(reader.GetAttribute("file"), this);
                            string targetpath = Path.Combine(targetDirectory.FullName, VariableResolver.Expand(reader.GetAttribute("targetpath"), this));

                            Log.InfoFormat("ProcessNode: Extracting {0} to {1}", file, targetpath);
                            Directory.CreateDirectory(Path.GetDirectoryName(targetpath));
                            _archive.ExtractFile(file, targetpath);
                        }
                        break;
                    case "extract-all":
                        {
                            string targetfolder = Path.Combine(targetDirectory.FullName, VariableResolver.Expand(reader.GetAttribute("targetfolder"), this));

                            Log.InfoFormat("ProcessNode: Extracting {0} to {1}", "everything", targetfolder);
                            _archive.ExtractAllFiles(targetfolder);
                        }
                        break;
                    case "extract-filter":
                        {
                            string filter = VariableResolver.Expand(reader.GetAttribute("filter"), this);
                            string targetfolder = Path.Combine(targetDirectory.FullName, VariableResolver.Expand(reader.GetAttribute("targetfolder"), this));

                            if (string.IsNullOrEmpty(filter))
                                filter = "*";

                            foreach (string entry in FileFilterUtil.FilterFiles(_archive.GetFileEntries(), filter))
                            {
                                string targetpath = Path.Combine(targetfolder.Replace('/', Path.DirectorySeparatorChar), entry.Replace('/', Path.DirectorySeparatorChar));
                                Log.InfoFormat("ProcessNode: Extracting {0} to {1}", entry, targetpath);
                                Directory.CreateDirectory(Path.GetDirectoryName(targetpath));
                                _archive.ExtractFile(entry, targetpath);
                            }
                            e.Progress += step;
                        }
                        break;
                    case "delete":
                        {
                            string targetpath = Path.Combine(targetDirectory.FullName, VariableResolver.Expand(reader.GetAttribute("targetpath"), this));

                            Log.InfoFormat("ProcessNode: Deleting {0}", targetpath);
                            File.Delete(targetpath);
                            e.Progress += step;
                        }
                        break;
                    case "delete-folder":
                        {
                            string filter = VariableResolver.Expand(reader.GetAttribute("filter"), this);
                            string folder = Path.Combine(targetDirectory.FullName, VariableResolver.Expand(reader.GetAttribute("targetfolder"), this));
                            var d = new DirectoryInfo(folder);
                            foreach (var file in d.GetFiles(string.IsNullOrEmpty(filter) ? "*" : filter, SearchOption.AllDirectories))
                            {
                                Log.InfoFormat("ProcessNode: Deleting {0}", file.FullName);
                                file.Delete();
                                if (!file.Directory.GetFiles().Any())
                                    file.Directory.Delete();
                            }
                            if (!d.GetFiles().Any())
                                d.Delete();
                            e.Progress += step;
                        }
                        break;
                    case "uninject":
                        {
                            string target = Path.Combine(targetDirectory.FullName, VariableResolver.Expand(reader.GetAttribute("targetpath"), this));
                            string filter = VariableResolver.Expand(reader.GetAttribute("filter"), this);

                            Directory.CreateDirectory(Path.GetDirectoryName(target));

                            ZipArchive targetZip;
                            if (File.Exists(target))
                                targetZip = ZipArchive.Open(target);
                            else
                            {
                                targetZip = ZipArchive.Create();
                                break;
                            }
                            targetZip.DeflateCompressionLevel = SharpCompress.Compressor.Deflate.CompressionLevel.BestCompression;

                            foreach (ZipArchiveEntry entry in from x in targetZip.Entries where FileFilterUtil.IsMatch(x.FilePath, filter) select x)
                            {
                                Log.InfoFormat("ProcessNode: Removing {0} from {1}", entry.FilePath, target);
                                targetZip.RemoveEntry(entry);
                            }

                            Log.InfoFormat("ProcessNode: Updating {0}", target);
                            targetZip.SaveTo(target + ".~", CompressionType.Deflate);
                            targetZip.Dispose();

                            File.Delete(target);
                            File.Move(target + ".~", target);
                            e.Progress += step;
                        }
                        break;
                    case "inject":
                        {
                            string target = Path.Combine(targetDirectory.FullName, VariableResolver.Expand(reader.GetAttribute("targetpath"), this));
                            string filter = VariableResolver.Expand(reader.GetAttribute("filter"), this);

                            Directory.CreateDirectory(Path.GetDirectoryName(target));

                            ZipArchive targetZip;
                            if (File.Exists(target))
                                targetZip = ZipArchive.Open(target);
                            else
                                targetZip = ZipArchive.Create();
                            targetZip.DeflateCompressionLevel = SharpCompress.Compressor.Deflate.CompressionLevel.BestCompression;

                            foreach (string entry in FileFilterUtil.FilterFiles(_archive.GetFileEntries(), filter))
                            {
                                if (entry.EndsWith("/") || entry.EndsWith(Path.DirectorySeparatorChar.ToString())) continue;

                                MemoryStream ms = new MemoryStream();
                                using (var s = _archive.OpenFile(entry))
                                {
                                    //s.CopyTo(ms);
                                    int i = 1;
                                    while (i > 0)
                                    {
                                        byte[] buffer = new byte[2048];
                                        i = s.Read(buffer, 0, buffer.Length);
                                        if (i > 0)
                                            ms.Write(buffer, 0, i);
                                    }
                                }
                                ms.Flush();
                                ms.Seek(0, SeekOrigin.Begin);
                                var entriesWhichAreSame = (from zipentry in targetZip.Entries where zipentry.FilePath.Replace(Path.DirectorySeparatorChar, '\\') == entry select zipentry).ToArray();
                                if (entriesWhichAreSame.Any())
                                    foreach (var zipentry in entriesWhichAreSame)
                                    {
                                        Log.InfoFormat("ProcessNode: Removing {0} from {1}", zipentry.FilePath, target);
                                        targetZip.RemoveEntry(zipentry);
                                    }
                                Log.InfoFormat("ProcessNode: Adding {0} to {1}", entry, target);
                                targetZip.AddEntry(entry, ms);
                            }

                            Log.InfoFormat("ProcessNode: Updating {0}", target);
                            targetZip.SaveTo(target + ".~", CompressionType.Deflate);
                            targetZip.Dispose();

                            File.Delete(target);
                            File.Move(target + ".~", target);
                            e.Progress += step;
                        }
                        break;
                    case "move":
                        {
                            string sourcePath = Path.Combine(targetDirectory.FullName, VariableResolver.Expand(reader.GetAttribute("path"), this));
                            string targetPath = Path.Combine(targetDirectory.FullName, VariableResolver.Expand(reader.GetAttribute("targetpath"), this));

                            Log.InfoFormat("ProcessNode: Moving {0} to {1}", sourcePath, targetPath);
                            Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
                            File.Move(sourcePath, targetPath);
                            e.Progress += step;
                        }
                        break;
                    case "download":
                        {
                            string sourcePath = VariableResolver.Expand(reader.GetAttribute("url"), this);
                            string targetPath = Path.Combine(targetDirectory.FullName, VariableResolver.Expand(reader.GetAttribute("targetpath"), this));

                            e.Status = StatusType.Downloading;
                            _repository.OnStatusChanged(e);
                            Log.InfoFormat("ProcessNode: Downloading {0} to {1}", sourcePath, targetPath);
                            new System.Net.WebClient().DownloadFile(new Uri(sourcePath), targetPath);

                            e.Progress += step;
                        }
                        break;
                    default:
                        Log.WarnFormat("ProcessNode: Unknown step {0}", reader.Name);
                        break;
                }
            } while (reader.Read());
            _repository.OnStatusChanged(e);
        }