Пример #1
0
        public static string AddWithChildren(XmlNode xnod, Int32 intLevel)
        {
            XmlNode xnodWorking;
            string  strValue = (string)xnod.Value;

            if (strValue != null)
            {
                strValue = ":" + strValue;
            }
            strSpace += strValue;

            if (xnod.NodeType == XmlNodeType.Element)
            {
                XmlNamedNodeMap mapAttributes = xnod.Attributes;
                foreach (XmlNode xnodAttribute in mapAttributes)
                {
                    strSpace += ":" + xnodAttribute.Value;
                }
                if (xnod.HasChildNodes)
                {
                    xnodWorking = xnod.FirstChild;
                    while (xnodWorking != null)
                    {
                        AddWithChildren(xnodWorking, intLevel + 1);
                        xnodWorking = xnodWorking.NextSibling;
                    }
                }
            }
            return(strSpace);
        }
Пример #2
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode PrimaryNode = document.FirstChild; PrimaryNode != null; PrimaryNode = PrimaryNode.NextSibling)
         {
             if ("list".Equals(PrimaryNode.Name))
             {
                 for (XmlNode SecundaryNode = PrimaryNode.FirstChild; SecundaryNode != null; SecundaryNode = SecundaryNode.NextSibling)
                 {
                     XmlNamedNodeMap itemMap = SecundaryNode.Attributes;
                     if ("event".Equals(SecundaryNode.Name))
                     {
                         list.Add(new EventUpModel
                         {
                             startDate = int.Parse(itemMap.GetNamedItem("start_date").Value),
                             endDate   = int.Parse(itemMap.GetNamedItem("end_date").Value),
                             percentXp = int.Parse(itemMap.GetNamedItem("percent_exp").Value),
                             percentGp = int.Parse(itemMap.GetNamedItem("percent_gold").Value)
                         });
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
 }
Пример #3
0
        private Dictionary <String, String> readnode(XmlNode node, string buildedKey, string lastkey)
        {
            string nodeName = node.Name;
            //   int thislength=0;
            bool newone = false;

            if (nodeName.ToLower() != "#text")
            {
                //buildedKey = nodeName;
                String[] a = buildedKey.Split('.');
                if (a.Length == 2)
                {
                    //System.out.println("Added hashmap to array!" + parsedMap.get("company.staff.firstname"));
                    if (parsedMap.Count > 0)
                    {
                        GWDataRow newrow = new GWDataRow(parsedMap);
                        data.Add(newrow);
                        parsedMap = new Dictionary <string, string>();
                        newone    = false;
                    }
                    //    parsedMap.put(buildedKey,node.getNodeValue());
                }
                //  System.out.println ("B  is " + buildedKey + " " + a.length);
                lastkey     = buildedKey;
                buildedKey += "." + nodeName;
            }
            //else nodeName = "";
            if (node.Value != null)
            {
                buildedKey = buildedKey.Substring(1);
                string v = node.Value.Replace("%26", "&");
                parsedMap.Add(buildedKey, v);
                //     System.out.println(newone);

                //        System.out.println ("This key: " + buildedKey + " Last: " + lastkey);
                //	System.out.println("Adding to parsedmap");
            }

            if (node.NodeType == XmlNodeType.Element)
            {
                if (node.Attributes.Count > 0)
                {
                    XmlNamedNodeMap startAttr = node.Attributes;
                    for (int i = 0; i < startAttr.Count; i++)
                    {
                        XmlNode attr = startAttr.Item(i);
                        // buildedKey += attr.getNodeValue() + ".";
                    }
                }
            }
            int         c        = 0;
            XmlNodeList children = node.ChildNodes;

            foreach (XmlNode child in children)
            {
                c++;
                readnode(child, buildedKey, lastkey);
            }
            return(parsedMap);
        }
Пример #4
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode xmlNode1 = document.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
         {
             if ("list".Equals(xmlNode1.Name))
             {
                 for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                 {
                     if ("mission".Equals(xmlNode2.Name))
                     {
                         XmlNamedNodeMap xml       = xmlNode2.Attributes;
                         int             id        = int.Parse(xml.GetNamedItem("id").Value);
                         int             blueOrder = int.Parse(xml.GetNamedItem("blueOrder").Value);
                         int             exp       = int.Parse(xml.GetNamedItem("exp").Value);
                         int             gold      = int.Parse(xml.GetNamedItem("gold").Value);
                         awards.Add(new MisAwards(id, blueOrder, exp, gold));
                     }
                 }
             }
         }
     }
     catch (XmlException ex)
     {
         Logger.Exception(ex);
     }
 }
Пример #5
0
        public Position(XmlNode positionNode)
        {
            this.InitialConditions = new List <Double>(3)
            {
                0, 0, 0
            };
            XmlNamedNodeMap mapAttributes = positionNode.Attributes;

            //Add the attributes to the TreeView
            foreach (XmlNode xnodAttribute in mapAttributes)
            {
                // We're going to find nodes by name here people!
                if (xnodAttribute.Name == "TaskType")
                {
                    this.Type = (PositionType)Enum.Parse(typeof(PositionType), xnodAttribute.Value);
                }
                else if (xnodAttribute.Name == "ICs")
                {
                    String   temp = xnodAttribute.Value.Split(new char[] { '{', '}' })[1];
                    String[] vals = temp.Split(',');
                    this.InitialConditions[1] = Convert.ToDouble(vals[0]);
                    this.InitialConditions[0] = Convert.ToDouble(vals[1]);
                    this.InitialConditions[2] = Convert.ToDouble(vals[2]);
                }
            }
        }
        /// <summary>
        /// Displays a FilePicker to the user and after they select the file
        /// it is loaded and displayed on the map.
        /// </summary>
        private async void LoadGPXFile()
        {
            FileOpenPicker fileOpenPicker = new FileOpenPicker();

            fileOpenPicker.FileTypeFilter.Add(".gpx");
            StorageFile gpxFile = await fileOpenPicker.PickSingleFileAsync();

            if (gpxFile != null)
            {
                XmlDocument gpxDoc = await XmlDocument.LoadFromFileAsync(gpxFile);

                XmlNodeList pointNodes = gpxDoc.GetElementsByTagName("trkpt");

                LocationCollection gpxRoutePoints = new LocationCollection();

                foreach (IXmlNode node in pointNodes)
                {
                    XmlNamedNodeMap attributes = node.Attributes;

                    try
                    {
                        IXmlNode latitudeAttribute = attributes.GetNamedItem("lat");
                        double   latitude          = double.Parse(latitudeAttribute.InnerText);

                        IXmlNode longitudeAttribute = attributes.GetNamedItem("lon");
                        double   longitude          = double.Parse(longitudeAttribute.InnerText);

                        gpxRoutePoints.Add(new Location(latitude, longitude));
                    }
                    catch
                    {
                        // Most likely if these values don't exist in the file it is
                        // formatted incorrectly or corrupt.  In a real app we would
                        // display some kind of error message to the user.
                    }
                }

                MapPolyline route = new MapPolyline();
                route.Color     = Windows.UI.Colors.Blue;
                route.Width     = 5;
                route.Locations = gpxRoutePoints;
                mRouteLayer.Shapes.Add(route);

                Pushpin startPin = new Pushpin();
                startPin.Text = "S";
                mMapLayer.Children.Add(startPin);
                MapLayer.SetPosition(startPin, gpxRoutePoints[0]);

                Pushpin endPin = new Pushpin();
                endPin.Text = "E";
                mMapLayer.Children.Add(endPin);
                MapLayer.SetPosition(endPin, gpxRoutePoints[gpxRoutePoints.Count - 1]);

                LocationRect bestRouteView = new LocationRect(gpxRoutePoints);
                map.SetView(bestRouteView);

                mMarkerPin.Visibility = Visibility.Collapsed;
                mMapLayer.Children.Add(mMarkerPin);
            }
        }
Пример #7
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode primaryNode = document.FirstChild; primaryNode != null; primaryNode = primaryNode.NextSibling)
         {
             if ("list".Equals(primaryNode.Name))
             {
                 for (XmlNode secundaryNode = primaryNode.FirstChild; secundaryNode != null; secundaryNode = secundaryNode.NextSibling)
                 {
                     if ("Chara".Equals(secundaryNode.Name))
                     {
                         XmlNamedNodeMap xml   = secundaryNode.Attributes;
                         CharaModel      chara = new CharaModel
                         {
                             Id   = int.Parse(xml.GetNamedItem("Id").Value),
                             Type = int.Parse(xml.GetNamedItem("Type").Value),
                             Life = int.Parse(xml.GetNamedItem("Life").Value)
                         };
                         charas.Add(chara);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
 }
Пример #8
0
        public void xmlview(string xmlPath)
        {
            xmlDoc.Load(xmlPath);
            //取根结点
            var root = xmlDoc.DocumentElement;

            //获取根节点的所有子节点列表
            childlist = root.ChildNodes;
            ListBox1.Items.Clear();
            for (int i = 0; i < childlist.Count; i++)
            //遍历xml中所有的调用函数和对应值
            {
                XmlNode         child     = childlist[i];
                XmlNamedNodeMap childattr = child.Attributes;
                string          funcvalue = childattr.GetNamedItem("function").Value.ToString();
                string          textvalue = child.InnerText.ToString();
                string          ifvalue   = childattr.GetNamedItem("if_value").Value.ToString();
                string          iffind    = childattr.GetNamedItem("if_find").Value.ToString();
                ValueList.Add((funcvalue, textvalue, ifvalue, iffind));


                if (funcvalue == "pictureclick")
                {
                    ListBox1.Items.Add("点击" + textvalue);
                }
                if (funcvalue == "IF")
                {
                    ListBox1.Items.Add(string.Format("{0}{1} 时点击 {2}", iffind, textvalue, ifvalue));
                }
            }
        }
        private static void AddChildren(XmlNode xmlNode, int level)
        {
            XmlNode childXmlNode;
            //Here we speciy padding; th enumber of spaces based on the level in the XML tree
            string pad = new string(' ', level * 2);

            Console.WriteLine(pad + xmlNode.Name + "(" + xmlNode.NodeType.ToString() + ": " + xmlNode.Value + "");
            //Here we extract possible attributes
            if (xmlNode.NodeType == XmlNodeType.Element)
            {

                XmlNamedNodeMap mapAttributes = xmlNode.Attributes;
                for (int i = 0; i < mapAttributes.Count; i++)
                {
                    Console.WriteLine(pad + " " + mapAttributes.Item(i).Name + "=" + mapAttributes.Item(i).Value);
                }

            }
            //Here we call recursively o all children of the current node
            if (xmlNode.HasChildNodes)
            {
                childXmlNode = xmlNode.FirstChild;
                while (childXmlNode != null)
                {
                    AddChildren(childXmlNode, level + 1);
                    childXmlNode = childXmlNode.NextSibling;
                }
            }
        }
Пример #10
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode xmlNode1 = document.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
         {
             if ("list".Equals(xmlNode1.Name))
             {
                 for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                 {
                     if ("cupom".Equals(xmlNode2.Name))
                     {
                         XmlNamedNodeMap xml   = xmlNode2.Attributes;
                         CupomFlag       cupom = new CupomFlag
                         {
                             ItemId     = int.Parse(xml.GetNamedItem("item_id").Value),
                             EffectFlag = (CupomEffects)int.Parse(xml.GetNamedItem("effect_flag").Value)
                         };
                         Effects.Add(cupom);
                     }
                 }
             }
         }
     }
     catch (XmlException ex)
     {
         Logger.Exception(ex);
     }
 }
Пример #11
0
        /// <summary>
        /// This Method is only for debugging the TaskList nodes.
        /// </summary>
        /// <param name="AXnod"></param>
        /// <param name="ALevel"></param>
        private static void ChildDisplay(XmlNode AXnod, int ALevel)
        {
            XmlNode xnodWorking;
            String  pad = new String(' ', ALevel * 2);

            TLogging.Log(pad + AXnod.Name + "(" + AXnod.NodeType.ToString() + ": <" + AXnod.Value + ">)");

            if (AXnod.NodeType == XmlNodeType.Element)
            {
                XmlNamedNodeMap mapAttributes = AXnod.Attributes;

                for (int i = 0; i < mapAttributes.Count; i++)
                {
                    TLogging.Log(pad + " " + mapAttributes.Item(i).Name + " = " + mapAttributes.Item(i).Value);
                }
            }

            if (AXnod.HasChildNodes)
            {
                xnodWorking = AXnod.FirstChild;

                while (xnodWorking != null)
                {
                    ChildDisplay(xnodWorking, ALevel + 1);
                    xnodWorking = xnodWorking.NextSibling;
                }
            }
        }
Пример #12
0
        public NullSerial(XmlNode _node)

        {
            if (!_node.Name.Equals(NULL_ATTR))
            {
                //throw new ClassFoundException(_node.getNodeName(), NULL_ATTR);
                throw new ClassFoundException();
            }
            XmlNamedNodeMap map_   = _node.Attributes;
            XmlNode         field_ = map_.GetNamedItem(FIELD);

            if (field_ != null)
            {
                setField(field_.Value);
            }
            XmlNode className_ = map_.GetNamedItem(CLASS);

            if (className_ != null)
            {
                setClassName(className_.Value);
            }
            XmlNode keyOfMap_ = map_.GetNamedItem(KEY);

            if (keyOfMap_ != null)
            {
                setKeyOfMap(true);
            }
        }
Пример #13
0
        public void Initialize()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(@"data\xml\map_region.xml");
            if (doc.DocumentElement == null)
            {
                return;
            }

            XmlNodeList nodes = doc.DocumentElement.SelectNodes("/list/map");
            int         count = 0;

            if (nodes != null)
            {
                foreach (XmlNode node in nodes)
                {
                    XmlElement ownerElement = node.Attributes?[0].OwnerElement;
                    if ((ownerElement == null) || (node.Attributes == null) || !ownerElement.Name.EqualsIgnoreCase("map"))
                    {
                        continue;
                    }

                    XmlNamedNodeMap attrs = node.Attributes;
                    int             rY    = Convert.ToInt32(attrs.GetNamedItem("geoY").Value) - 10;
                    for (int rX = 0; rX < RegionsX; rX++)
                    {
                        Regions[rX, rY] = Convert.ToInt32(attrs.GetNamedItem($"geoX_{rX + 16}").Value);
                        count++;
                    }
                }
            }

            Log.Info($"MapRegionTable: Loaded {count} regions.");
        }
Пример #14
0
        /// <summary>
        /// Obtain the specified XML attribute from the specified node.
        /// </summary>
        /// <param name="e">The XML node to obtain an attribute from.</param>
        /// <param name="name">The name of the attribute.</param>
        /// <returns>Returns the value of the attribute.</returns>
        private String GetXMLAttribute(XmlNode e, String name)
        {
            XmlNamedNodeMap map  = e.Attributes;
            XmlNode         attr = map.GetNamedItem(name);

            return(attr.Value);
        }
 public static string nodeToApplicationPool(XmlNode node)                    //Function that returns Application Pool names from sent Nodes
 {
     try
     {
         foreach (XmlNode grandNode in node.ChildNodes)
         {
             if (grandNode.Attributes.Count != 0)
             {
                 if (grandNode.Name == "application")
                 {
                     XmlNamedNodeMap attributes2     = grandNode.Attributes;
                     XmlNode         applicationPool = attributes2.GetNamedItem("applicationPool");
                     if (applicationPool != null)
                     {
                         return(applicationPool.Value);
                     }
                 }
             }
         }
     }
     catch
     {
         return(null);
     }
     return(null);
 }
Пример #16
0
        private void XmlToDataTable(XmlNode xnod)
        {
            DataRow dr = dt.NewRow();
            XmlNode xnodWorking;

            //如果是元素节点,获取它的属性
            if (xnod.NodeType == XmlNodeType.Element)
            {
                XmlNamedNodeMap mapAttributes = xnod.Attributes;
                if (mapAttributes.Count > 0)
                {
                    dr[0] = mapAttributes.Item(0).Value;
                    dr[1] = mapAttributes.Item(1).Value;
                    dr[2] = mapAttributes.Item(2).Value;
                    dr[3] = mapAttributes.Item(3).Value;
                    dr[4] = mapAttributes.Item(4).Value;
                    dr[5] = mapAttributes.Item(5).Value;
                    dr[6] = mapAttributes.Item(6).Value;
                    dt.Rows.Add(dr);
                }

                //如果还有子节点,就递归地调用这个程序
                if (xnod.HasChildNodes)
                {
                    xnodWorking = xnod.FirstChild;
                    while (xnodWorking != null)
                    {
                        XmlToDataTable(xnodWorking);
                        xnodWorking = xnodWorking.NextSibling;
                    }
                }
            }
        }
Пример #17
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode xmlNode1 = document.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
         {
             if ("list".Equals(xmlNode1.Name))
             {
                 for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                 {
                     if ("rank".Equals(xmlNode2.Name))
                     {
                         XmlNamedNodeMap xml = xmlNode2.Attributes;
                         ranks.Add(new RankModel(byte.Parse(xml.GetNamedItem("id").Value),
                                                 int.Parse(xml.GetNamedItem("onNextLevel").Value), 0,
                                                 int.Parse(xml.GetNamedItem("onAllExp").Value)));
                     }
                 }
             }
         }
     }
     catch (XmlException ex)
     {
         Logger.Exception(ex);
     }
 }
Пример #18
0
 private static void AnimsXML(XmlNode xmlNode, ObjModel obj)
 {
     for (XmlNode xmlNode5 = xmlNode.FirstChild; xmlNode5 != null; xmlNode5 = xmlNode5.NextSibling)
     {
         if ("Anims".Equals(xmlNode5.Name))
         {
             for (XmlNode xmlNode6 = xmlNode5.FirstChild; xmlNode6 != null; xmlNode6 = xmlNode6.NextSibling)
             {
                 if ("Sync".Equals(xmlNode6.Name))
                 {
                     XmlNamedNodeMap xml6 = xmlNode6.Attributes;
                     AnimModel       anim = new AnimModel
                     {
                         Id        = int.Parse(xml6.GetNamedItem("Id").Value),
                         Duration  = float.Parse(xml6.GetNamedItem("Date").Value),
                         NextAnim  = int.Parse(xml6.GetNamedItem("Next").Value),
                         OtherObj  = int.Parse(xml6.GetNamedItem("OtherOBJ").Value),
                         OtherAnim = int.Parse(xml6.GetNamedItem("OtherANIM").Value)
                     };
                     if (anim.Id == 0)
                     {
                         obj.NoInstaSync = true;
                     }
                     if (anim.Id != 255)
                     {
                         obj.UpdateId = 3;
                     }
                     obj.Anims.Add(anim);
                 }
             }
         }
     }
 }
Пример #19
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode xmlNode1 = document.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
         {
             if ("list".Equals(xmlNode1.Name))
             {
                 for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                 {
                     if ("Map".Equals(xmlNode2.Name))
                     {
                         XmlNamedNodeMap xml = xmlNode2.Attributes;
                         MapModel        map = new MapModel
                         {
                             id = int.Parse(xml.GetNamedItem("Id").Value)
                         };
                         BombsXML(xmlNode2, map);
                         ObjectsXML(xmlNode2, map);
                         maps.Add(map);
                     }
                 }
             }
         }
     }
     catch (XmlException ex)
     {
         Logger.Warning(ex.ToString());
     }
 }
Пример #20
0
        private void Parcours(XmlNode node, string parent)
        {
            if (node.NodeType == XmlNodeType.Element)
            {
                if (node.Attributes.Count > 0)
                {
                    XmlNamedNodeMap mapAttributes = node.Attributes;
                    XmlNode         att           = mapAttributes.GetNamedItem("name");
                    string          name          = parent + "." + (att != null ? att.Value : node.Name);
                    string          value         = mapAttributes.GetNamedItem("value").Value.ToString();

                    // Ajout dans le dictionnaire
                    configurationOptions.Add(name, value);
                }
            }

            if (node.HasChildNodes)
            {
                XmlNode nodeChild = node.FirstChild;
                while (nodeChild != null)
                {
                    if (parent == null || parent.Equals(string.Empty))
                    {
                        Parcours(nodeChild, node.Name);
                    }
                    else
                    {
                        Parcours(nodeChild, parent + "." + node.Name);
                    }
                    nodeChild = nodeChild.NextSibling;
                }
            }
        }
Пример #21
0
 private static void BombsXML(XmlNode xmlNode, MapModel map)
 {
     for (XmlNode xmlNode3 = xmlNode.FirstChild; xmlNode3 != null; xmlNode3 = xmlNode3.NextSibling)
     {
         if ("BombPositions".Equals(xmlNode3.Name))
         {
             for (XmlNode xmlNode4 = xmlNode3.FirstChild; xmlNode4 != null; xmlNode4 = xmlNode4.NextSibling)
             {
                 if ("Bomb".Equals(xmlNode4.Name))
                 {
                     XmlNamedNodeMap xml4 = xmlNode4.Attributes;
                     BombPosition    bomb = new BombPosition
                     {
                         X = float.Parse(xml4.GetNamedItem("X").Value),
                         Y = float.Parse(xml4.GetNamedItem("Y").Value),
                         Z = float.Parse(xml4.GetNamedItem("Z").Value)
                     };
                     bomb.Position = new Half3(bomb.X, bomb.Y, bomb.Z);
                     if (bomb.X == 0 && bomb.Y == 0 && bomb.Z == 0)
                     {
                         bomb.Everywhere = true;
                     }
                     map.bombs.Add(bomb);
                 }
             }
         }
     }
 }
Пример #22
0
 private static void AnimsXML(XmlNode xmlNode, ObjModel obj)
 {
     for (XmlNode xmlNode1 = xmlNode.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
     {
         if ("Anims".Equals(xmlNode1.Name))
         {
             for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
             {
                 if ("Anim".Equals(xmlNode2.Name))
                 {
                     XmlNamedNodeMap attributes = (XmlNamedNodeMap)xmlNode2.Attributes;
                     AnimModel       animModel  = new AnimModel()
                     {
                         _id        = int.Parse(attributes.GetNamedItem("Id").Value),
                         _duration  = float.Parse(attributes.GetNamedItem("Duration").Value),
                         _nextAnim  = int.Parse(attributes.GetNamedItem("Next").Value),
                         _otherObj  = int.Parse(attributes.GetNamedItem("OtherOBJ").Value),
                         _otherAnim = int.Parse(attributes.GetNamedItem("OtherANIM").Value)
                     };
                     if (animModel._id == 0)
                     {
                         obj._noInstaSync = true;
                     }
                     if (animModel._id != (int)byte.MaxValue)
                     {
                         obj._updateId = 3;
                     }
                     obj._anims.Add(animModel);
                 }
             }
         }
     }
 }
Пример #23
0
 private static void BombsXML(XmlNode xmlNode, MapModel map)
 {
     for (XmlNode xmlNode1 = xmlNode.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
     {
         if ("BombPositions".Equals(xmlNode1.Name))
         {
             for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
             {
                 if ("Bomb".Equals(xmlNode2.Name))
                 {
                     XmlNamedNodeMap attributes   = (XmlNamedNodeMap)xmlNode2.Attributes;
                     BombPosition    bombPosition = new BombPosition()
                     {
                         X = float.Parse(attributes.GetNamedItem("X").Value),
                         Y = float.Parse(attributes.GetNamedItem("Y").Value),
                         Z = float.Parse(attributes.GetNamedItem("Z").Value)
                     };
                     bombPosition.Position = new Half3(bombPosition.X, bombPosition.Y, bombPosition.Z);
                     if ((double)bombPosition.X == 0.0 && (double)bombPosition.Y == 0.0 && (double)bombPosition.Z == 0.0)
                     {
                         bombPosition.Everywhere = true;
                     }
                     map._bombs.Add(bombPosition);
                 }
             }
         }
     }
 }
Пример #24
0
        public static void Initialize()
        {
            XmlDocument doc = new XmlDocument();

            string[] xmlFilesArray = Directory.GetFiles(@"data\xml\npcs\");
            try
            {
                StatsSet set = new StatsSet();

                foreach (string i in xmlFilesArray)
                {
                    doc.Load(i);

                    XmlNodeList nodes = doc.DocumentElement?.SelectNodes("/list/npc");

                    if (nodes == null)
                    {
                        continue;
                    }

                    foreach (XmlNode node in nodes)
                    {
                        XmlElement ownerElement = node.Attributes?[0].OwnerElement;
                        if (ownerElement != null && node.Attributes != null && ownerElement.Name == "npc")
                        {
                            XmlNamedNodeMap attrs = node.Attributes;

                            int npcId      = int.Parse(attrs.GetNamedItem("id").Value);
                            int templateId = attrs.GetNamedItem("idTemplate") == null ? npcId : int.Parse(attrs.GetNamedItem("idTemplate").Value);

                            set.Set("id", npcId);
                            set.Set("idTemplate", templateId);
                            set.Set("name", attrs.GetNamedItem("name").Value);
                            set.Set("title", attrs.GetNamedItem("title").Value);

                            foreach (XmlNode innerData in node.ChildNodes)
                            {
                                if (innerData.Attributes["name"] != null && innerData.Attributes["val"] != null)
                                {
                                    string value = innerData.Attributes["val"].Value;
                                    string name  = innerData.Attributes["name"].Value;

                                    set.Set(name, value);
                                }
                            }

                            _npcs.Add(npcId, new NpcTemplate(set));
                        }
                        set.Clear();
                    }
                }

                Log.Info($"Loaded {_npcs.Count} npcs.");
            }
            catch (Exception e)
            {
                Log.Error(e, "Error parsing NPC templates: ");
            }
        }
Пример #25
0
        public void TestMethod1()
        {
            //const string folderPath = @"./data/xml/classes";
            //foreach (string file in Directory.EnumerateFiles(folderPath, "*.xml"))
            //{
            //    //string contents = File.ReadAllText(file);
            //}

            XmlDocument doc = new XmlDocument();

            string[] xmlFilesArray = Directory.GetFiles(@"data\xml\classes\");
            foreach (string i in xmlFilesArray)
            {
                doc.Load(i);

                XmlNodeList nodes = doc.DocumentElement?.SelectNodes("/list/class");

                if (nodes == null)
                {
                    continue;
                }

                foreach (XmlNode node in nodes)
                {
                    XmlElement ownerElement = node.Attributes?[0].OwnerElement;
                    if ((ownerElement == null) || !"class".Equals(ownerElement.Name))
                    {
                        continue;
                    }

                    //ClassIds classId = (ClassIds)int.Parse(attrs.Item(0).Value);
                    StatsSet set = new StatsSet();

                    for (XmlNode cd = node.FirstChild; cd != null; cd = cd.NextSibling)
                    {
                        if ((cd.NextSibling != null) && "set".Equals(cd.NextSibling.Name) && (cd.NextSibling != null))
                        {
                            XmlNamedNodeMap attrs = cd.NextSibling.Attributes;
                            if (attrs == null)
                            {
                                continue;
                            }

                            string name  = attrs.GetNamedItem("name").Value;
                            string value = attrs.GetNamedItem("val").Value;
                            set.Set(name, value);
                        }
                        else
                        {
                            break;
                        }
                    }
                    ////PcTemplate pcTempl = new PcTemplate(classId, set);
                    ////templates.Add((int)pcTempl.ClassId, pcTempl);
                    //System.Diagnostics.Trace.WriteLine($"Added template for: {pcTempl.ClassId}");
                }
            }
        }
Пример #26
0
        /// <summary>Read Element named mime-type. </summary>
        private MimeType ReadMimeType(XmlElement element)
        {
            String          name        = null;
            String          description = null;
            MimeType        type;
            XmlNamedNodeMap attrs = element.Attributes;

            for (int i = 0; i < attrs.Count; i++)
            {
                XmlAttribute attr = (XmlAttribute)attrs.Item(i);
                if (attr.Name.Equals("name"))
                {
                    name = attr.Value;
                }
                else if (attr.Name.Equals("description"))
                {
                    description = attr.Value;
                }
            }
            if ((name == null) || (name.Trim().Equals("")))
            {
                return(null);
            }

            try
            {
                //Trace.WriteLine("Mime type:" + name);
                type = new MimeType(name);
            }
            catch (MimeTypeException mte)
            {
                // Mime Type not valid... just ignore it
                Trace.WriteLine(mte.ToString() + " ... Ignoring!");
                return(null);
            }

            type.Description = description;

            XmlNodeList nodes = element.ChildNodes;

            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes.Item(i);
                if (Convert.ToInt16(node.NodeType) == (short)XmlNodeType.Element)
                {
                    XmlElement nodeElement = (XmlElement)node;
                    if (nodeElement.Name.Equals("ext"))
                    {
                        ReadExt(nodeElement, type);
                    }
                    else if (nodeElement.Name.Equals("magic"))
                    {
                        ReadMagic(nodeElement, type);
                    }
                }
            }
            return(type);
        }
Пример #27
0
        protected static string ConvertNodeToJSON(XmlNode node)
        {
            if (CUIUtility.IsNullOrUndefined(node))
            {
                return(string.Empty);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("{\"name\" : \"");
            sb.Append(UIUtility.EcmaScriptStringLiteralEncode(node.NodeName));
            sb.Append("\",\"attrs\": {");

            XmlNamedNodeMap attrs    = node.Attributes;
            int             numAttrs = attrs.Length;

            for (int idx = 0; idx < numAttrs; idx++)
            {
                XmlNode attr = attrs[idx];

                if (idx != 0)
                {
                    sb.Append(",");
                }

                sb.Append("\"");
                sb.Append(UIUtility.EcmaScriptStringLiteralEncode(attr.NodeName));
                sb.Append("\":\"");
                sb.Append(UIUtility.EcmaScriptStringLiteralEncode(attr.NodeValue));
                sb.Append("\"");
            }

            sb.Append("},children:[");

            bool first = true;

            foreach (XmlNode child in node.ChildNodes)
            {
                if (string.Compare(child.NodeName, "#text") == 0)
                {
                    continue;
                }

                if (first)
                {
                    first = false;
                }
                else
                {
                    sb.Append(",");
                }

                sb.Append(ConvertNodeToJSON(child));
            }

            sb.Append("]}");
            return(sb.ToString());
        }
Пример #28
0
        /// <summary>
        /// XmlNamedNodeMap에 Node를 추가한다.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="nodeMap"></param>
        /// <returns>실패시 null 반환</returns>
        public XmlNode SetNamedItem(XmlNamedNodeMap nodeMap, XmlNode node)
        {
            if (nodeMap != null && node != null)
            {
                return(nodeMap.SetNamedItem(node));
            }

            return(null);
        }
Пример #29
0
        private static void Parse(string path, int cupomId)
        {
            XmlDocument xmlDocument = new XmlDocument();

            using (FileStream fileStream = new FileStream(path, FileMode.Open))
            {
                try
                {
                    xmlDocument.Load(fileStream);
                    for (XmlNode xmlNode1 = xmlDocument.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
                    {
                        if ("list".Equals(xmlNode1.Name))
                        {
                            XmlNamedNodeMap xml2 = xmlNode1.Attributes;
                            RandomBoxModel  box  = new RandomBoxModel
                            {
                                itemsCount = int.Parse(xml2.GetNamedItem("count").Value)
                            };
                            for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                            {
                                if ("item".Equals(xmlNode2.Name))
                                {
                                    XmlNamedNodeMap xml    = xmlNode2.Attributes;
                                    ItemsModel      item   = null;
                                    int             itemId = int.Parse(xml.GetNamedItem("id").Value);
                                    int             count  = int.Parse(xml.GetNamedItem("count").Value);
                                    if (itemId > 0)
                                    {
                                        item = new ItemsModel(itemId)
                                        {
                                            name  = "Randombox",
                                            equip = byte.Parse(xml.GetNamedItem("equip").Value),
                                            count = count
                                        };
                                    }
                                    box.items.Add(new RandomBoxItem
                                    {
                                        index   = int.Parse(xml.GetNamedItem("index").Value),
                                        percent = int.Parse(xml.GetNamedItem("percent").Value),
                                        special = bool.Parse(xml.GetNamedItem("special").Value),
                                        count   = count,
                                        item    = item
                                    });
                                }
                            }
                            box.SetTopPercent();
                            boxes.Add(cupomId, box);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex);
                }
                fileStream.Close();
            }
        }
Пример #30
0
            public void Add(ItemType type, XmlNamedNodeMap attrs)
            {
                Item item = GetItem(type);

                for (int k = 0; k < attrs.Count; k++)
                {
                    item.nodes.Add(attrs.Item(k));
                }
            }
Пример #31
0
 protected string GetAttributeValue(string attributeName, XmlNamedNodeMap attributes)
 {
     return attributes.GetNamedItem(attributeName)?.InnerText;
 }