public static DatabaseConfiguration Read (string file)
		{
			DatabaseConfiguration config = new DatabaseConfiguration ();
			
			StreamReader s = new StreamReader (file);
			using (s) {
				XmlTextReader tr = new XmlTextReader (s);
				tr.MoveToContent ();
				tr.ReadStartElement ("Configuration");
				tr.MoveToContent ();
				tr.ReadStartElement ("DisabledAddins");
				tr.MoveToContent ();
				if (!tr.IsEmptyElement) {
					while (tr.NodeType != XmlNodeType.EndElement) {
						if (tr.NodeType == XmlNodeType.Element) {
							if (tr.LocalName == "Addin")
								config.DisabledAddins.Add (tr.ReadElementString ());
						}
						else
							tr.Skip ();
						tr.MoveToContent ();
					}
				}
			}
			return config;
		}
        public void LoadPIDSetting_FromXmlTextReader(ref XmlTextReader xml_reader)
        {
            this.cycle_time_in_seconds = Double.Parse(xml_reader.ReadElementString("cycle_time_in_seconds"));

            xml_reader.ReadStartElement("outer_zone");
            this.proportional_band_EachZone[0] = Double.Parse(xml_reader.ReadElementString("proportional_band"));
            this.offset_EachZone[0] = Double.Parse(xml_reader.ReadElementString("offset"));
            this.reset_EachZone[0] = Double.Parse(xml_reader.ReadElementString("reset"));
            this.rate_EachZone[0] = Double.Parse(xml_reader.ReadElementString("rate"));
            xml_reader.ReadEndElement();

            xml_reader.ReadStartElement("sample_zone");
            this.proportional_band_EachZone[1] = Double.Parse(xml_reader.ReadElementString("proportional_band"));
            this.offset_EachZone[1] = Double.Parse(xml_reader.ReadElementString("offset"));
            this.reset_EachZone[1] = Double.Parse(xml_reader.ReadElementString("reset"));
            this.rate_EachZone[1] = Double.Parse(xml_reader.ReadElementString("rate"));
            xml_reader.ReadEndElement();

            xml_reader.ReadStartElement("inner_zone");
            this.proportional_band_EachZone[2] = Double.Parse(xml_reader.ReadElementString("proportional_band"));
            this.offset_EachZone[2] = Double.Parse(xml_reader.ReadElementString("offset"));
            this.reset_EachZone[2] = Double.Parse(xml_reader.ReadElementString("reset"));
            this.rate_EachZone[2] = Double.Parse(xml_reader.ReadElementString("rate"));
            xml_reader.ReadEndElement();
        }
Esempio n. 3
0
        public void Load(System.Xml.XmlTextReader tr, string localName)
        {
            int count;

            tr.ReadStartElement(localName);

            _viewDirectionRecentIsFirst = tr.ReadElementContentAsBoolean("DirectionRecentFirst", string.Empty);

            count = XmlConvert.ToInt32(tr.GetAttribute("Count"));
            tr.ReadStartElement("ColumnWidths");
            _columnWidths = new double[count];
            for (int i = 0; i < count; i++)
            {
                _columnWidths[i] = tr.ReadElementContentAsInt("Width", string.Empty);
            }
            if (count > 0)
            {
                tr.ReadEndElement(); // ColumnWidths
            }
            if (null != _view)
            {
                _view.ColumnWidths = _columnWidths;
                _columnWidths      = null;
            }

            tr.ReadEndElement();
        }
Esempio n. 4
0
        public static DatabaseConfiguration Read(string file)
        {
            DatabaseConfiguration config = new DatabaseConfiguration ();

            StreamReader s = new StreamReader (file);
            using (s) {
                XmlTextReader tr = new XmlTextReader (s);
                tr.MoveToContent ();
                if (tr.IsEmptyElement)
                    return config;

                tr.ReadStartElement ("Configuration");
                tr.MoveToContent ();

                while (tr.NodeType != XmlNodeType.EndElement) {

                    if (tr.NodeType != XmlNodeType.Element || tr.IsEmptyElement) {
                        tr.Skip ();
                    }
                    else if (tr.LocalName == "DisabledAddins") {
                        // For back compatibility
                        tr.ReadStartElement ();
                        tr.MoveToContent ();
                        while (tr.NodeType != XmlNodeType.EndElement) {
                            if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin")
                                config.addinStatus [tr.ReadElementString ()] = null;
                            else
                                tr.Skip ();
                            tr.MoveToContent ();
                        }
                        tr.ReadEndElement ();
                    }
                    else if (tr.LocalName == "AddinStatus") {
                        tr.ReadStartElement ();
                        tr.MoveToContent ();
                        while (tr.NodeType != XmlNodeType.EndElement) {
                            if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin") {
                                string aid = tr.GetAttribute ("id");
                                string senabled = tr.GetAttribute ("enabled");
                                if (senabled.Length == 0 || senabled == "True")
                                    config.addinStatus [aid] = config;
                                else
                                    config.addinStatus [aid] = null;
                            }
                            tr.Skip ();
                            tr.MoveToContent ();
                        }
                        tr.ReadEndElement ();
                    }
                    tr.MoveToContent ();
                }
            }
            return config;
        }
 /// <summary>
 /// Parses the input stream and return the associated project type. The stream should point to a project file (csproj or vbproj)
 /// </summary>
 /// <param name="st">The stream</param>
 /// <returns>the project type</returns>
 public static string GetProjectType(Stream st)
 {
     XmlTextReader rd = new XmlTextReader(st);
     using (rd)
     {
         rd.ReadStartElement("Project");
         rd.ReadToNextSibling("PropertyGroup");
         rd.ReadStartElement("PropertyGroup");
         rd.ReadToNextSibling("OutputType");
         return rd.ReadString();
     }
 }
        public static AAInventoryItemBase Deserialize(string serialization)
        {
            AAInventoryItemBase item = new AAInventoryItemBase();

            StringReader sr = new StringReader(serialization);
            XmlTextReader xtr = new XmlTextReader(sr);

            xtr.ReadStartElement("InventoryItem");

            item.Name = xtr.ReadElementString("Name");
            item.ID = UUID.Parse(xtr.ReadElementString("ID"));
            item.InvType = Convert.ToInt32(xtr.ReadElementString("InvType"));
            item.CreatorId = xtr.ReadElementString("CreatorUUID");
            item.CreationDate = Convert.ToInt32(xtr.ReadElementString("CreationDate"));
            item.Owner = UUID.Parse(xtr.ReadElementString("Owner"));
            item.Description = xtr.ReadElementString("Description");
            item.AssetType = Convert.ToInt32(xtr.ReadElementString("AssetType"));
            item.AssetID = UUID.Parse(xtr.ReadElementString("AssetID"));
            item.SaleType = Convert.ToByte(xtr.ReadElementString("SaleType"));
            item.SalePrice = Convert.ToInt32(xtr.ReadElementString("SalePrice"));
            item.BasePermissions = Convert.ToUInt32(xtr.ReadElementString("BasePermissions"));
            item.CurrentPermissions = Convert.ToUInt32(xtr.ReadElementString("CurrentPermissions"));
            item.EveryOnePermissions = Convert.ToUInt32(xtr.ReadElementString("EveryOnePermissions"));
            item.NextPermissions = Convert.ToUInt32(xtr.ReadElementString("NextPermissions"));
            item.Flags = Convert.ToUInt32(xtr.ReadElementString("Flags"));
            item.GroupID = UUID.Parse(xtr.ReadElementString("GroupID"));
            item.GroupOwned = Convert.ToBoolean(xtr.ReadElementString("GroupOwned"));

            xtr.ReadEndElement();

            xtr.Close();
            sr.Close();

            return item;
        }
Esempio n. 7
0
        public override void Deserialize(Node node, string data)
        {
            TextReader tr = new StringReader(data);
            Dictionary<string, object> properties = new Dictionary<string, object>();

            using(XmlReader xmlReader = new XmlTextReader(tr))
            {
                xmlReader.ReadStartElement("root");
                do {
                    if (xmlReader.NodeType == XmlNodeType.Element) {
                        string name = xmlReader.Name;
                        if (xmlReader.Read()) {
                            switch (xmlReader.NodeType) {
                            case XmlNodeType.Text:
                                properties.Add(name, xmlReader.ReadContentAs(xmlReader.ValueType, null));
                                break;
                            case XmlNodeType.Element:
                                List<object> objs = new List<object>();
                                while(xmlReader.Read() && xmlReader.NodeType != XmlNodeType.EndElement) {
                                    if (xmlReader.Name == "item")
                                        objs.Add(xmlReader.ReadElementContentAs(xmlReader.ValueType, null));
                                }
                                properties.Add(name, objs.ToArray());
                                break;
                            }

                        }

                    }
                } while(xmlReader.Read());
            }

            UpdateNode (node, properties);
        }
Esempio n. 8
0
        static void PopulateCache(Dictionary<Key, GenericXmlSecurityToken> cache, Stream stream)
        {
            XmlTextReader reader = new XmlTextReader(stream);
            while (reader.IsStartElement("Entry"))
            {
                reader.ReadStartElement();
                Uri target = new Uri(reader.ReadElementString("Target"));
                string issuerStr = reader.ReadElementString("Issuer");
                Uri issuer = string.IsNullOrEmpty(issuerStr) ? null : new Uri(issuerStr);

                reader.ReadStartElement("Token");
                reader.ReadStartElement("XML");
                XmlDocument doc = new XmlDocument();
                XmlElement tokenXml = doc.ReadNode(reader) as XmlElement;
                reader.ReadEndElement();
                byte[] key = Convert.FromBase64String(reader.ReadElementString("Key"));
                reader.ReadElementString("Id");
                DateTime validFrom = Convert.ToDateTime(reader.ReadElementString("ValidFrom"));
                DateTime validTo = Convert.ToDateTime(reader.ReadElementString("ValidTo"));
                WSSecurityTokenSerializer serializer = new WSSecurityTokenSerializer();
                reader.ReadStartElement("InternalTokenReference");
                SecurityKeyIdentifierClause internalReference = serializer.ReadKeyIdentifierClause(reader);
                reader.ReadEndElement();
                reader.ReadStartElement("ExternalTokenReference");
                SecurityKeyIdentifierClause externalReference = serializer.ReadKeyIdentifierClause(reader);
                reader.ReadEndElement();
                reader.ReadEndElement(); // token
                reader.ReadEndElement(); // entry

                List<IAuthorizationPolicy> policies = new List<IAuthorizationPolicy>();
                GenericXmlSecurityToken token = new GenericXmlSecurityToken(tokenXml, new BinarySecretSecurityToken(key), validFrom, validTo, internalReference, externalReference,
                    new ReadOnlyCollection<IAuthorizationPolicy>(policies));
                cache.Add(new Key(target, issuer), token);
            }
        }
Esempio n. 9
0
        private void FromXml(String xmlStream)
        {
            try
            {
                StringReader stringReader = new StringReader(xmlStream);
                XmlTextReader reader = new XmlTextReader(stringReader);
                while (reader.EOF == false)
                {
                    reader.ReadStartElement("ValidationContext");
                    String generateSummaryResults = reader.ReadElementString("GenerateSummaryResults");
                    if (generateSummaryResults == "true")
                    {
                        _generateSummaryResults = true;
                    }
                    String generateDetailedResults = reader.ReadElementString("GenerateDetailedResults");
                    if (generateDetailedResults == "true")
                    {
                        _generateDetailedResults = true;
                    }
                    // ...
                    // EVS Specific Context properties
                    // ...
                    reader.ReadElementString("EvsSpecificContext");

                    reader.ReadEndElement();
                }
                reader.Close();
            }
            catch (Exception e)
            {
                String message = String.Format("Failed to FromXml() DVTK DICOM EVS Validation Context XML stream: \"{0}\". Error: \"{1}\"", xmlStream, e.Message);
                throw new Exception(message, e);
            }
        }
Esempio n. 10
0
 public  async Task<int> Execute()
 {
     using (var reader = new StreamReader(FileName, Encode))
     {
         XmlReader xmlReader = new XmlTextReader(reader);
         xmlReader.ReadStartElement();
         while (xmlReader.Read())
         {
             var xdoc = new XmlDocument();
             string content = xmlReader.ReadOuterXml();
             if (string.IsNullOrEmpty(content))
             {
                 break;
             }
             xdoc.LoadXml(content);
             for (int i = 0; i < xdoc.DocumentElement.ChildNodes.Count; i++)
             {
                 var xele = xdoc.DocumentElement.ChildNodes[i] as XmlElement;
                 if (i != 0)
                 {
                     _logger.InfoLine(",");
                 }
                 _logger.InfoLine(xele.InnerText);
             }
             _logger.InfoLine("");
         }
         xmlReader.Close();
         return 0;
     }
 }
Esempio n. 11
0
        public static VexObject Load(string fileFullPathAndName)
        {
            VexObject vo;
            string rootFolder = Path.GetDirectoryName(fileFullPathAndName);
            string fileNameOnly = Path.GetFileNameWithoutExtension(fileFullPathAndName);
            Environment.CurrentDirectory = rootFolder;

            string definitionsFolder = "";
            string instancesFolder = "";
            uint rootId = 0;

            vo = new VexObject(fileNameOnly);

            FileStream fs = new FileStream(fileFullPathAndName, FileMode.Open);
            XmlTextReader r = new XmlTextReader(fs);

            r.ReadStartElement("UIL");

            while (r.Read())
            {
                if (r.IsStartElement())
                {
                    switch (r.Name)
                    {
                        case "DefinitionsFolder":
                            if (r.Read())
                            {
                                definitionsFolder = r.Value.Trim();
                            }
                            break;
                        case "InstancesFolder":
                            if (r.Read())
                            {
                                instancesFolder = r.Value.Trim();
                            }
                            break;
                        case "RootId":
                            if (r.Read())
                            {
                                rootId = uint.Parse(r.Value.Trim(), NumberStyles.Any);
                            }
                            break;
                    }
                }
            }

            fs.Close();

            string defsPath = rootFolder + Path.DirectorySeparatorChar + fileNameOnly + definitionsFolder;
            LoadDefinitions(defsPath, vo);

            string instsPath = rootFolder + Path.DirectorySeparatorChar + fileNameOnly + instancesFolder;
            LoadInstances(instsPath, vo);

            vo.Root = (Timeline)vo.Definitions[rootId];

            return vo;
        }
Esempio n. 12
0
 public new void Load(XmlTextReader reader)
 {
     reader.ReadStartElement("Placeable");
     _canEnter = (reader.GetAttribute("canEnter", "").Trim() == "1");
     _doesWarp = (reader.GetAttribute("doesWarp", "").Trim() == "1");
     _name = reader.GetAttribute("name", "").Trim();
     base.Load(reader);
     reader.ReadEndElement();
 }
Esempio n. 13
0
        public static CharacterInformation Read(XmlTextReader reader)
        {
            reader.ReadStartElement ("Class");
            string name = reader.ReadElementString ("Name");
            reader.ReadEndElement();

            return new CharacterInformation
            {
                Class = name
            };
        }
 void Load(string fileName)
 {
     // chargement des valeurs des options depuis le fichier Config.xml
     try
     {
         using (XmlTextReader reader = new XmlTextReader(fileName))
         {
             reader.ReadStartElement("Config");
             do
             {
                 if (!reader.IsStartElement()) continue;
                 string value = reader.ReadString();
                 switch (reader.Name)
                 {
                     case "VLCPath": VLCPath = value; break;
                     case "DVDLetter": DVDLetter = value; break;
                     case "VlcPort": VlcPort = value; break;
                     case "SoundExts": SoundExts = value; break;
                     case "PictureExts": PictureExts = value; break;
                     case "VideoExts": VideoExts = value; break;
                     case "AudioLanguage": AudioLanguage = value; break;
                     case "SubLanguage": SubLanguage = value; break;
                     case "ShowVLC": ShowVLC = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "Transcode":
                         switch (value.ToUpper())
                         {
                             case "MPGA": TranscodeAudio = AudioTranscode.MPGA; break;
                             case "A52": TranscodeAudio = AudioTranscode.A52; break;
                             case "PC": TranscodeAudio = AudioTranscode.PC; break;
                             default: TranscodeAudio = AudioTranscode.None; break;
                         }
                         break;
                     case "StartMinimized": StartMinimized = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "MinimizeToTray": MinimizeToTray = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "FFMpegInterlace": FFMpegInterlace = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "HalfScale": HalfScale = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "LIRCActive": LIRCActive = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "TranscodeVB": TranscodeVB = value; break;
                     case "PCControlAllowed": PCControlAllowed = Convert.ToBoolean(value); break;
                     case "LessIconsInExplorer": LessIconsInExplorer = Convert.ToBoolean(value); break;
                     case "BlackBkgnds": BlackBkgnds = Convert.ToBoolean(value); break;
                     case "TranscodeVideo":
                         switch (value.ToUpper())
                         {
                             case "MPG2": TranscodeVideo = VideoTranscode.MPG2; break;
                             default: TranscodeVideo = VideoTranscode.None; break;
                         }
                         break;
                 }
             } while (reader.Read());
         }
     }
     catch (FileNotFoundException) { }
 }
Esempio n. 15
0
        public static NamingRules LoadRules(string xmlPath)
        {
            NamingRules namingRules = new NamingRules();
            namingRules.rules = new List<NamingRule>();

            using (XmlReader reader = new XmlTextReader(xmlPath))
            {
                reader.ReadStartElement("Rules");
                reader.ReadStartElement("GeneralSettings");
                
                reader.ReadStartElement("FilenameRegex");
                namingRules.filenameRegex = reader.ReadString();
                reader.ReadEndElement();
                
                reader.ReadStartElement("ContextDepth");
                namingRules.contextDepth = reader.ReadContentAsInt();
                if (namingRules.ContextDepth < 1 || namingRules.ContextDepth > 4)
                    throw new FormatException("Context Depth must be between 1 and 4");
                reader.ReadEndElement();
                
                reader.ReadStartElement("ContextSeparator");
                namingRules.contextSeparator = reader.ReadString();
                reader.ReadEndElement();
                
                reader.ReadEndElement();
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        System.Diagnostics.Debug.Assert(reader.Name == "Rules");
                        break;
                    }
                    //if (reader.IsStartElement())
                    //    System.Diagnostics.Debug.Assert(reader.Name == "Rule");
                    reader.ReadStartElement("Rule");
                    //reader.Read();

                    reader.ReadStartElement("SearchString");
                    string regex = reader.ReadString();
                    reader.ReadEndElement();
                    reader.ReadStartElement("Replacement");
                    string replacement = reader.ReadString();
                    reader.ReadEndElement();
                    reader.ReadEndElement();
                    namingRules.rules.Add(new NamingRule(regex, replacement));
                }
                reader.ReadEndElement();
            }
            return namingRules;
        }
        public void Deserialize(string str)
        {
            using (TextReader textReader = new StringReader(str))
            using (XmlReader xmlReader = new XmlTextReader(textReader))
            {
                xmlReader.ReadStartElement();

                xmlReader.ReadStartElement();
                this.Id = new Guid(xmlReader.ReadContentAsString());
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value1 = xmlReader.ReadContentAsInt();
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value2 = xmlReader.ReadContentAsDateTime();
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value3 = xmlReader.ReadContentAsString();
                xmlReader.ReadEndElement();

                xmlReader.ReadStartElement();
                this.Value4 = xmlReader.ReadContentAsDecimal();
                xmlReader.ReadEndElement();

                xmlReader.ReadEndElement();
            }
        }
 public static SensorData ReadSensorData(string soap) {
      SensorData sd;
      XmlTextReader xmread;
      sd = null;
      try {
           sd = new SensorData();
           using (System.IO.StringReader read = new System.IO.StringReader(soap)) {
                xmread = new XmlTextReader(read);
                xmread.ReadStartElement("SensorDataContainer");
                xmread.ReadStartElement("Sensor");
                xmread.ReadStartElement("HasMotion");
                sd.HasMotion = bool.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadStartElement("NodeId");
                sd.NodeId = int.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadStartElement("PowerLevel");
                sd.PowerLevel = int.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadStartElement("TimeStamp");
                sd.TimeStamp = DateTime.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadEndElement();
                xmread.ReadEndElement();
           }
      } catch (Exception) {
           throw;
      }
      return (sd);
 }
        /// <summary> 
        /// Decodes a function call from Flash. 
        /// </summary> 
        /// <param name="xml">The XML string representing the function call.</param> 
        /// <returns>An ExternalInterfaceCall object representing the function call.</returns> 
        public static ExternalInterfaceCall DecodeInvoke(string xml)
        {
            XmlTextReader reader = new XmlTextReader(xml, XmlNodeType.Document, null);

            reader.Read();

            string functionName = reader.GetAttribute("name");
            ExternalInterfaceCall result = new ExternalInterfaceCall(functionName);

            reader.ReadStartElement("invoke");
            reader.ReadStartElement("arguments");

            while (reader.NodeType != XmlNodeType.EndElement && reader.Name != "arguments")
            {
                result.AddArgument(ReadElement(reader));
            }

            reader.ReadEndElement();
            reader.ReadEndElement();

            return result;
        }
Esempio n. 19
0
        public static IList<GameObject> Load(XmlTextReader reader, string path)
        {
            List<GameObject> listGameObject = new List<GameObject>();
            reader.ReadStartElement("Objects");
            while (reader.NodeType != XmlNodeType.EndElement || reader.Name != "Objects")
            {
                reader.Read();
                if (reader.IsStartElement("Item"))
                {
                    GameObject g_obj = readGameObject(reader);
                    listGameObject.Add(g_obj);
                }
            }

            return listGameObject;
        }
Esempio n. 20
0
        //Copy code from SceneObjectSerializer.ProcessColor
        public static System.Drawing.Color DeSerializeColor(string colorString)
        {
            StringReader sr = new StringReader(colorString);
            XmlTextReader reader = new XmlTextReader(sr);

            System.Drawing.Color color = new System.Drawing.Color();

            reader.ReadStartElement("Color");
            if (reader.Name == "R")
            {
                float r = reader.ReadElementContentAsFloat("R", String.Empty);
                float g = reader.ReadElementContentAsFloat("G", String.Empty);
                float b = reader.ReadElementContentAsFloat("B", String.Empty);
                float a = reader.ReadElementContentAsFloat("A", String.Empty);
                color = System.Drawing.Color.FromArgb((int)a, (int)r, (int)g, (int)b);
                reader.ReadEndElement();
            }
            return color;
        }
Esempio n. 21
0
        public static ArcanaPlayer ReadCharacter(XmlTextReader reader)
        {
            reader.ReadStartElement ("Character");

            int id = Convert.ToInt32 (reader.ReadElementString ("CharacterID"));
            string name = reader.ReadElementString ("Name");
            string pclass = reader.ReadElementString ("Class");
            int level = Convert.ToInt32 (reader.ReadElementString ("Level"));

            reader.ReadEndElement ();

            ArcanaPlayer p = classConstructors[pclass] ();
            {
                p.CharacterID = id;
                p.Name = name;
                p.Class = pclass;
                p.Level = level;
            }
            return p;
        }
Esempio n. 22
0
 public static void Load()
 {
     using (FileStream strm = new FileStream(FileName, FileMode.Open))
     {
         Pairs.Clear();
         using (XmlReader reader = new XmlTextReader(strm))
         {
             reader.ReadStartElement("SimpleConfig");
             while (reader.Name == "parameter")
             {
                 string key = reader.GetAttribute("name");
                 string value = reader.GetAttribute("value");
                 Pairs[key] = value;
                 reader.Read();
             }
             reader.ReadEndElement();
             reader.Close();
         }
             
         strm.Close();
     }
 }
        private void calculateDistancesFromKml(XmlTextReader reader)
        {
            reader.ReadStartElement("kml");
            reader.Read();
            if (reader.Name == "Document" || reader.Name == "Folder"){
                string name = "";
                string coordinates;
                while (reader.Read()) {
                    if (reader.Name == "Placemark"){
                        while (reader.Read() && reader.Name != "Placemark"){
                            if (reader.Name == "name"){
                                name = reader.ReadElementString();
                            }
                            if (reader.Name == "LineString"){
                                while (reader.Read() && reader.Name != "LineString"){
                                    if (reader.Name == "coordinates"){
                                        CoordinatesDistanceSummarizer summarizer = new CoordinatesDistanceSummarizer();

                                        coordinates = reader.ReadElementString();

                                        KmlCoordinatesParser parser = new KmlCoordinatesParser(coordinates);
                                        double[] coordinate;
                                        while (parser.NextCoordinate(out coordinate)){
                                            summarizer.AddCoordinate(coordinate[1],coordinate[0]);
                                        }
                                        DistanceLine dl = new DistanceLine(name,summarizer.Summarize());
                                        distanceLines.Add(dl);

                                    }

                                }

                            }
                        }
                    }
                }
            }
        }
Esempio n. 24
0
        public void Load()
        {
            ReadWriteTestStructure ();

            // Load class templates
            string classTemplateRoot = Path.Combine (Environment.CurrentDirectory, "Content//classes.xml");

            using (XmlTextReader treader = new XmlTextReader (classTemplateRoot))
            {
                treader.ReadStartElement ("Classes");

                while (treader.Read () && treader.NodeType != XmlNodeType.EndElement)
                {
                    CharacterInformation template = ClassTemplateSerializer.Read (treader);
                    template.Texture = Moxy.ContentManager.Load<Texture2D> ("Interface//cf_" + template.Class.ToLower());
                    Classes.Add (template);
                }

                treader.ReadEndElement();
            }

            // Load all characters
            foreach (string file in Directory.EnumerateFiles (Path.Combine(Environment.CurrentDirectory, "saves")))
            {
                using (XmlTextReader reader = new XmlTextReader (file))
                {
                    reader.MoveToElement();

                    while (reader.Read())
                    {
                        ArcanaPlayer player = CharacterSerializer.ReadCharacter (reader);
                        Characters.Add (new CharacterInformation (player));
                        characters.Add (player.CharacterID, player);
                    }
                }
            }
        }
Esempio n. 25
0
		public object Deserialize(Stream inStream, ISoapMessage soapMessage) 
		{
			ArrayList headers = null;
			xmlReader = new XmlTextReader(inStream);
			xmlReader.WhitespaceHandling = WhitespaceHandling.None;
			mapper = new SoapTypeMapper(_binder);

			try
			{
				// SOAP-ENV:Envelope
				xmlReader.MoveToContent();
				xmlReader.ReadStartElement ();
				xmlReader.MoveToContent();
				
				// Read headers
				while (!(xmlReader.NodeType == XmlNodeType.Element && xmlReader.LocalName == "Body" && xmlReader.NamespaceURI == SoapTypeMapper.SoapEnvelopeNamespace))
				{
					if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.LocalName == "Header" && xmlReader.NamespaceURI == SoapTypeMapper.SoapEnvelopeNamespace)
					{
						if (headers == null) headers = new ArrayList ();
						DeserializeHeaders (headers);
					}
					else
						xmlReader.Skip ();
					xmlReader.MoveToContent();
				}
				
				// SOAP-ENV:Body
				xmlReader.ReadStartElement();
				xmlReader.MoveToContent();

				// The root object
				if (soapMessage != null)
				{
					if (DeserializeMessage (soapMessage)) {
						_topObjectId = NextAvailableId;
						RegisterObject (_topObjectId, soapMessage, null, 0, null, null);
					}
					xmlReader.MoveToContent();
					
					if (headers != null)
						soapMessage.Headers = (Header[]) headers.ToArray (typeof(Header));
				}
				
				while (xmlReader.NodeType != XmlNodeType.EndElement)
					Deserialize();
					
				// SOAP-ENV:Body
				xmlReader.ReadEndElement ();
				xmlReader.MoveToContent();

				// SOAP-ENV:Envelope
				xmlReader.ReadEndElement ();
			}
			finally 
			{
				if(xmlReader != null) xmlReader.Close();
			}

			return TopObject;
		}
Esempio n. 26
0
        public WearableCacheItem[] Get(UUID id)
        {
            if (m_URL == String.Empty)
                return null;

            int size = 0;

            using (RestClient rc = new RestClient(m_URL))
            {
                List<WearableCacheItem> ret = new List<WearableCacheItem>();
                rc.AddResourcePath("bakes");
                rc.AddResourcePath(id.ToString());

                rc.RequestMethod = "GET";

                try
                {
                    Stream s = rc.Request(m_Auth);

                    using (XmlTextReader sr = new XmlTextReader(s))
                    {
                        sr.ReadStartElement("BakedAppearance");
                        while (sr.LocalName == "BakedTexture")
                        {
                            string sTextureIndex = sr.GetAttribute("TextureIndex");
                            int lTextureIndex = Convert.ToInt32(sTextureIndex);
                            string sCacheId = sr.GetAttribute("CacheId");
                            UUID lCacheId = UUID.Zero;
                            if (!(UUID.TryParse(sCacheId, out lCacheId)))
                            {
                                // ??  Nothing here
                            }

                            ++size;

                            sr.ReadStartElement("BakedTexture");
                            AssetBase a = (AssetBase)m_serializer.Deserialize(sr);
                            ret.Add(new WearableCacheItem() { CacheId = lCacheId, TextureIndex = (uint)lTextureIndex, TextureAsset = a, TextureID = a.FullID });

                            sr.ReadEndElement();
                        }

                        m_log.DebugFormat("[XBakes]: read {0} textures for user {1}", ret.Count, id);
                    }

                    return ret.ToArray();
                }
                catch (XmlException)
                {
                    return null;
                }
            }
        }
		static string ReadGenericProjectType (string file)
		{
			using (XmlTextReader tr = new XmlTextReader (file)) {
				tr.MoveToContent ();
				if (tr.LocalName != "Project")
					return null;
				if (tr.IsEmptyElement)
					return null;
				tr.ReadStartElement ();
				tr.MoveToContent ();
				if (tr.LocalName != "PropertyGroup")
					return null;
				if (tr.IsEmptyElement)
					return null;
				tr.ReadStartElement ();
				tr.MoveToContent ();
				while (tr.NodeType != XmlNodeType.EndElement) {
					if (tr.NodeType == XmlNodeType.Element && !tr.IsEmptyElement && tr.LocalName == "ItemType")
						return tr.ReadElementString ();
					tr.Skip ();
				}
				return null;
			}
		}
        /// <summary>
        /// Deserialize settings
        /// </summary>
        /// <param name="serializedSettings"></param>
        /// <returns></returns>
        /// <exception cref="System.Xml.XmlException"></exception>
        public static InventoryItemBase Deserialize(string serialization)
        {
            InventoryItemBase item = new InventoryItemBase();

            using (XmlTextReader reader = new XmlTextReader(new StringReader(serialization)))
            {
                reader.ReadStartElement("InventoryItem");

                ExternalRepresentationUtils.ExecuteReadProcessors<InventoryItemBase>(
                    item, m_InventoryItemXmlProcessors, reader);

                reader.ReadEndElement(); // InventoryItem
            }

            //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID);
            return item;
        }      
Esempio n. 29
0
		public TemplateInfo[] ReadTemplates()
		{
			ArrayList result = new ArrayList();
			if(Directory.Exists(_templateFolder))
			{
				foreach(string dir in Directory.GetDirectories(_templateFolder))
				{
					string templateFile = Path.Combine(dir, "template.xml");
					if( File.Exists(templateFile ) )
					{
						XmlTextReader reader = new XmlTextReader(templateFile);
						try
						{
							reader.Read();
							reader.ReadStartElement("Template");
							reader.ReadStartElement("TemplateData");
							reader.ReadStartElement("Name");
							string name = reader.ReadString();
							DirectoryInfo directoryInfo = new DirectoryInfo(dir);
							TemplateInfo templateInfo = new TemplateInfo(name, directoryInfo.Name );
							result.Add(templateInfo);
						}
						finally
						{
							reader.Close();
						}
					}
				}
			}
			return (TemplateInfo[])result.ToArray(typeof(TemplateInfo));
		}
Esempio n. 30
0
        public void TestSerializeXml2()
        {
            TestHelper.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            string rpName = "My Little Pony";
            UUID rpUuid = UUID.Parse("00000000-0000-0000-0000-000000000064");
            UUID rpCreatorId = UUID.Parse("00000000-0000-0000-0000-000000000015");
            PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
//            Vector3 groupPosition = new Vector3(10, 20, 30);
//            Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
//            Vector3 offsetPosition = new Vector3(5, 10, 15);

            SceneObjectPart rp = new SceneObjectPart();
            rp.UUID = rpUuid;
            rp.Name = rpName;
            rp.CreatorID = rpCreatorId;
            rp.Shape = shape;

            SceneObjectGroup so = new SceneObjectGroup(rp);

            // Need to add the object to the scene so that the request to get script state succeeds
            m_scene.AddSceneObject(so);

            string xml2 = m_serialiserModule.SerializeGroupToXml2(so);

            XmlTextReader xtr = new XmlTextReader(new StringReader(xml2));
            xtr.ReadStartElement("SceneObjectGroup");
            xtr.ReadStartElement("SceneObjectPart");
           
            UUID uuid = UUID.Zero;
            string name = null;
            UUID creatorId = UUID.Zero;

            while (xtr.Read() && xtr.Name != "SceneObjectPart")
            {
                if (xtr.NodeType != XmlNodeType.Element)
                    continue;
                
                switch (xtr.Name)
                {
                    case "UUID":
                        xtr.ReadStartElement("UUID");
                        uuid = UUID.Parse(xtr.ReadElementString("Guid"));
                        xtr.ReadEndElement();
                        break;
                    case "Name":
                        name = xtr.ReadElementContentAsString();
                        break;
                    case "CreatorID":
                        xtr.ReadStartElement("CreatorID");
                        creatorId = UUID.Parse(xtr.ReadElementString("Guid"));
                        xtr.ReadEndElement();
                        break;
                }
            }

            xtr.ReadEndElement();
            xtr.ReadStartElement("OtherParts");
            xtr.ReadEndElement();
            xtr.Close();

            // TODO: More checks
            Assert.That(uuid, Is.EqualTo(rpUuid));
            Assert.That(name, Is.EqualTo(rpName));
            Assert.That(creatorId, Is.EqualTo(rpCreatorId));
        }
Esempio n. 31
0
        public static RegionSettings FromStream(Stream stream)
        {
            RegionSettings settings = new RegionSettings();
            System.Globalization.NumberFormatInfo nfi = Utils.EnUsCulture.NumberFormat;

            using (XmlTextReader xtr = new XmlTextReader(stream))
            {
                xtr.ReadStartElement("RegionSettings");
                xtr.ReadStartElement("General");

                while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
                {
                    switch (xtr.Name)
                    {
                        case "AllowDamage":
                            settings.AllowDamage = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "AllowLandResell":
                            settings.AllowLandResell = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "AllowLandJoinDivide":
                            settings.AllowLandJoinDivide = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "BlockFly":
                            settings.BlockFly = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "BlockLandShowInSearch":
                            settings.BlockLandShowInSearch = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "BlockTerraform":
                            settings.BlockTerraform = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "DisableCollisions":
                            settings.DisableCollisions = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "DisablePhysics":
                            settings.DisablePhysics = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "DisableScripts":
                            settings.DisableScripts = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "MaturityRating":
                            settings.MaturityRating = Int32.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "RestrictPushing":
                            settings.RestrictPushing = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "AgentLimit":
                            settings.AgentLimit = Int32.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "ObjectBonus":
                            settings.ObjectBonus = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                    }
                }

                xtr.ReadEndElement();
                xtr.ReadStartElement("GroundTextures");

                while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
                {
                    switch (xtr.Name)
                    {
                        case "Texture1":
                            settings.TerrainDetail0 = UUID.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "Texture2":
                            settings.TerrainDetail1 = UUID.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "Texture3":
                            settings.TerrainDetail2 = UUID.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "Texture4":
                            settings.TerrainDetail3 = UUID.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "ElevationLowSW":
                            settings.TerrainStartHeight00 = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                        case "ElevationLowNW":
                            settings.TerrainStartHeight01 = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                        case "ElevationLowSE":
                            settings.TerrainStartHeight10 = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                        case "ElevationLowNE":
                            settings.TerrainStartHeight11 = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                        case "ElevationHighSW":
                            settings.TerrainHeightRange00 = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                        case "ElevationHighNW":
                            settings.TerrainHeightRange01 = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                        case "ElevationHighSE":
                            settings.TerrainHeightRange10 = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                        case "ElevationHighNE":
                            settings.TerrainHeightRange11 = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                    }
                }

                xtr.ReadEndElement();
                xtr.ReadStartElement("Terrain");

                while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
                {
                    switch (xtr.Name)
                    {
                        case "WaterHeight":
                            settings.WaterHeight = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                        case "TerrainRaiseLimit":
                            settings.TerrainRaiseLimit = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                        case "TerrainLowerLimit":
                            settings.TerrainLowerLimit = Single.Parse(xtr.ReadElementContentAsString(), nfi);
                            break;
                        case "UseEstateSun":
                            settings.UseEstateSun = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "FixedSun":
                            settings.FixedSun = Boolean.Parse(xtr.ReadElementContentAsString());
                            break;
                    }
                }
            }

            return settings;
        }