ReadToFollowing() public method

public ReadToFollowing ( string name ) : bool
name string
return bool
Example #1
0
        /// <summary>
        /// Parse the results of the Bing search
        /// </summary>
        /// <param name="reader">The xml reader containing the search results</param>
        public Collection<Article> ParseItems(XmlReader reader, Feed ownerFeed)
        {
            Collection<Article> results = new Collection<Article>();
            reader.ReadToFollowing("item");
            do
            {
                if (reader.ReadToFollowing("title"))
                {
                    string name = reader.ReadElementContentAsString();

                    if (reader.ReadToFollowing("link"))
                    {
                        string uri = reader.ReadElementContentAsString();

                        // Assign feed information to Article object.
                        Article newResult = new Article
                        {
                            ArticleTitle = name,
                            ArticleBaseURI = uri
                        };
                        // Safely add the search result to the collection.
                        lock (_lockObject)
                        {
                            results.Add(newResult);
                        }
                    }
                }
            } while (reader.ReadToFollowing("item"));
            return results;
        }
Example #2
0
        private void ExtractDefinitions(XmlReader reader, ResultFile trx)
        {
            if (reader.ReadToFollowing("TestDefinitions"))
            {
                if (reader.ReadToDescendant("UnitTest"))
                {
                    do
                    {
                        var testId = Guid.Parse(reader.GetAttribute("id"));
                        var tempResult = trx.Results.First(result => result.TestId == testId);
                        tempResult.Storage = reader.GetAttribute("storage");

                        if (reader.ReadToFollowing("TestMethod"))
                        {
                            tempResult.CodeBase = reader.GetAttribute("codeBase");
                            tempResult.AdapterTypeName = reader.GetAttribute("adapterTypeName");
                            tempResult.ClassName = reader.GetAttribute("className");
                        }

                        reader.ReadToNextSibling("UnitTest");
                    }
                    while (reader.ReadToNextSibling("UnitTest"));
                }
            }
        }
Example #3
0
        private void ProcessItem(XmlReader reader)
        {
            reader.MoveToContent();

            Material tmpMaterial = new Material();

            tmpMaterial.name = reader.GetAttribute("displayname");
            tmpMaterial.type = reader.GetAttribute("type");

            if (reader.ReadToFollowing("ambient"))
            {
                reader.MoveToContent();
                tmpMaterial.ambient.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
                tmpMaterial.ambient.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
                tmpMaterial.ambient.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
                tmpMaterial.ambient.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
            }
            if (reader.ReadToFollowing("specular"))
            {
                reader.MoveToContent();
                tmpMaterial.specular.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
                tmpMaterial.specular.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
                tmpMaterial.specular.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
                tmpMaterial.specular.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
            }
            if (reader.ReadToFollowing("diffuse"))
            {
                reader.MoveToContent();
                tmpMaterial.diffuse.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
                tmpMaterial.diffuse.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
                tmpMaterial.diffuse.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
                tmpMaterial.diffuse.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
            }
            if (reader.ReadToFollowing("emissive"))
            {
                reader.MoveToContent();
                tmpMaterial.emission.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
                tmpMaterial.emission.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
                tmpMaterial.emission.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
                tmpMaterial.emission.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
            }
            if (reader.ReadToFollowing("shininess"))
            {
                reader.MoveToContent();
                tmpMaterial.shininess = (float)Convert.ToDouble(reader.GetAttribute("value").Replace(".", ","));
            }
            if (reader.ReadToFollowing("texture"))
            {
                reader.MoveToContent();
                tmpMaterial.LoadTexture(reader.GetAttribute("file"));
            }
            this.lstMaterial.Add(tmpMaterial);
        }
Example #4
0
        protected override PlayInfo AnalysisData(System.Xml.XmlReader reader)
        {
            reader.ReadToFollowing("channel");

            Dictionary <int, PlayInfo.Item> playInfoItems = new Dictionary <int, PlayInfo.Item>();

            while (reader.Read())
            {
                if (reader.Name == "item")
                {
                    if (reader.GetAttribute("bitrate") == null || reader.GetAttribute("ft") == null)
                    {
                        continue;
                    }
                    int           bitrate  = Convert.ToInt32(reader.GetAttribute("bitrate"));
                    int           ft       = Convert.ToInt32(reader.GetAttribute("ft"));
                    string        rid      = reader.GetAttribute("rid");
                    PlayInfo.Item playInfo = new PlayInfo.Item(bitrate, ft, rid, null);
                    playInfoItems.Add(ft, playInfo);
                }

                if (reader.Name == "dt" && reader.NodeType != XmlNodeType.EndElement)
                {
                    int             ft = Convert.ToInt32(reader.GetAttribute("ft"));
                    PlayInfo.DTInfo dt = new PlayInfo.DTInfo();
                    reader.ReadToFollowing("sh");
                    reader.Read();
                    dt.Sh = reader.Value;
                    reader.ReadToFollowing("st");
                    reader.Read();
                    dt.St = reader.Value;
                    reader.ReadToFollowing("bwt");
                    reader.Read();
                    dt.Bwt = Convert.ToInt32(reader.Value);
                    if (playInfoItems.ContainsKey(ft))
                    {
                        playInfoItems[ft].DtInfo = dt;
                    }
                }
            }

            PlayInfo retPlayInfo = new PlayInfo();

            foreach (PlayInfo.Item item in playInfoItems.Values)
            {
                retPlayInfo.Add(item);
            }

            return(retPlayInfo);
        }
Example #5
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadToFollowing(xmlFlujogramaType.Name);

            XmlSerializer serializer = new XmlSerializer(xmlFlujogramaType);

            FlujogramaDef = serializer.Deserialize(reader) as IFlujograma;


            //EntidadIDentificable.IdEntidad = FlujogramaDef.IdEntidad;
            //EntidadIDentificable.Entidad = FlujogramaDef.Entidad;
            reader.ReadToFollowing(xmlEstadoType.Name);
            if (reader.Name.Equals(xmlEstadoType.Name))
            {
                serializer = new XmlSerializer(xmlEstadoType);

                EstadoActual = serializer.Deserialize(reader) as IEstado;

                EstadoActual.Flujograma = FlujogramaDef;
            }
            reader.ReadToFollowing(xmlTransicionType.Name);
            if (reader.Name.Equals(xmlTransicionType.Name))
            {
                serializer = new XmlSerializer(xmlTransicionType);

                UltimaTransicion            = serializer.Deserialize(reader) as ITransicion;
                UltimaTransicion.Flujograma = FlujogramaDef;
                UltimaTransicion.Origen     = FlujogramaDef.Estados[UltimaTransicion.Origen.Estado];
                UltimaTransicion.Destino    = FlujogramaDef.Estados[UltimaTransicion.Destino.Estado];
            }
            reader.ReadToFollowing("Historico");
            if (reader.Name.Equals("Historico"))
            {
                XmlReader hijos = reader.ReadSubtree();

                serializer = new XmlSerializer(xmlTransicionType);

                while (hijos.ReadToFollowing(xmlTransicionType.Name))
                {
                    ITransicion tran = serializer.Deserialize(hijos) as ITransicion;

                    tran.Flujograma = FlujogramaDef;
                    tran.Origen     = FlujogramaDef.Estados[tran.Origen.Estado];
                    tran.Destino    = FlujogramaDef.Estados[tran.Destino.Estado];

                    _procesosAnteriores.Add(tran.FechaTransicion, tran);
                }
            }
        }
        /// <summary>
        /// Deserialize a scene object from the original xml format
        /// </summary>
        /// <param name="xmlData"></param>
        /// <returns>The scene object deserialized.  Null on failure.</returns>
        public static SceneObjectGroup FromOriginalXmlFormat(XmlReader reader)
        {
            //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
            //int time = System.Environment.TickCount;

            SceneObjectGroup sceneObject = null;

            try
            {
                int           linkNum;

                reader.ReadToFollowing("RootPart");
                reader.ReadToFollowing("SceneObjectPart");
                sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
                reader.ReadToFollowing("OtherParts");

                if(reader.IsEmptyElement)
                {
                    /* do not try to read parts on empty elements */
                }
                else if (reader.ReadToDescendant("Part"))
                {
                    do
                    {
                        if (reader.ReadToDescendant("SceneObjectPart"))
                        {
                            SceneObjectPart part = SceneObjectPart.FromXml(reader);
                            linkNum = part.LinkNum;
                            sceneObject.AddPart(part);
                            part.LinkNum = linkNum;
                            part.TrimPermissions();
                        }
                    }                    
                    while (reader.ReadToNextSibling("Part"));
                }

                // Script state may, or may not, exist. Not having any, is NOT
                // ever a problem.
                sceneObject.LoadScriptState(reader);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed.  Exception {0}", e);
                return null;
            }

            return sceneObject;
        }
Example #7
0
        public static IList<FileDto> Load(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            if (!reader.ReadToFollowing("Translations", Ns))
                return null;

            var files = new List<FileDto>();

            while (true)
            {
                if (!reader.Read())
                    return null;
                if (reader.NodeType == XmlNodeType.Whitespace)
                    continue;
                if (reader.NodeType == XmlNodeType.EndElement)
                    break;
                if (reader.NodeType != XmlNodeType.Element)
                    return null;

                var file = ReadFile(reader);
                if (file == null)
                    return null;

                files.Add(file);
            }

            return files;
        }
Example #8
0
 public string GetValue(string key)
 {
     _reader = XmlReader.Create(_configFile);
     _reader.ReadToFollowing(key);
     _reader.MoveToFirstAttribute();
     return _reader.Value;
 }
		private void readItems(XmlReader reader) {
			reader.ReadToFollowing ("ItemDatabase");
			bool continueReading = reader.ReadToDescendant ("Item");

			while (continueReading) {
				//Read all information from the .xml-file
				reader.ReadToDescendant ("Id");
				int id = reader.ReadElementContentAsInt ();
				reader.ReadToNextSibling ("Name");
				string name = reader.ReadElementContentAsString ();
				reader.ReadToNextSibling ("Description");
				string desc = reader.ReadElementContentAsString ();
				reader.ReadToNextSibling ("Value");
				int value = reader.ReadElementContentAsInt ();
				reader.ReadToNextSibling ("Type");
				string type = reader.ReadElementContentAsString ();
				ItemType t = type.StringToType ();

				//And add the item to the database
				Item i = new Item (name, desc, value, t, id);

				//check for attributes and add them to the item
				checkForAttributes(reader, i);

				//Add the item to the databse and read end element
				items.Add(i);
				reader.ReadEndElement ();
				//Check if there is another item to read
				continueReading = reader.ReadToNextSibling ("Item");
			}
		}
Example #10
0
        /// <summary>
        /// Generate object from its XML representation</summary>
        /// <param name="reader">XmlReader stream from which object is deserialized</param>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.ReadToFollowing(this.GetType().Name))
            {
                reader.ReadStartElement(this.GetType().Name);
                if (reader.LocalName == typeof(TabLayout).Name || reader.LocalName == "MultiContent") // MultiContent is old name and is used here for compatibility with old saved layouts
                {
                    DockedContent = new TabLayout(Root, reader.ReadSubtree());
                    if (DockedContent.Children.Count > 0)
                    {
                        ContentSettings contentSettings = DockedContent.Children[0].Settings;
                        Left   = contentSettings.Location.X;
                        Top    = contentSettings.Location.Y;
                        Width  = contentSettings.Size.Width;
                        Height = contentSettings.Size.Height;

                        Width  = Math.Max(Width, SystemParameters.MinimumWindowWidth);
                        Height = Math.Max(Height, SystemParameters.MinimumWindowHeight);
                        Left   = Math.Max(SystemParameters.VirtualScreenLeft,
                                          Math.Min(Left, SystemParameters.VirtualScreenWidth + SystemParameters.VirtualScreenLeft - Width));
                        Top = Math.Max(SystemParameters.VirtualScreenTop,
                                       Math.Min(Top, SystemParameters.VirtualScreenHeight + SystemParameters.VirtualScreenTop - Height));

                        reader.ReadEndElement();
                    }
                }
                reader.ReadEndElement();
            }
        }
        /// <summary>
        /// 分析集合大小
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        protected virtual int AnalysisCount(System.Xml.XmlReader reader)
        {
            if (reader.ReadToFollowing("count"))
            {
                var count = reader.ReadElementContentAsInt();
                if (reader.IsStartElement("page_count"))
                {
                    var pageCount = reader.ReadElementContentAsInt();
                    if (reader.IsStartElement("countInPage"))
                    {
                        var countInPage = reader.ReadElementContentAsInt();
                        if (reader.IsStartElement("page"))
                        {
                            var pageIndex = reader.ReadElementContentAsInt();

                            /*
                             * 总个数是否小于每页的个数,小于的话第一页返回总个数,其余页返回0
                             * 不小于判断是哪页,其余页返回每页个数,最后一页算一下还剩下多少页
                             */
                            return(count > countInPage ?
                                   (pageIndex > pageCount ? 0 : (pageIndex == pageCount) ? count - (pageIndex - 1) * countInPage : countInPage) :
                                   (pageIndex > 1 ? 0 : count));
                        }
                    }
                }
            }
            return(20);
        }
Example #12
0
        /// <summary>
        /// 分析集合大小
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        protected ChannelSearchOutlineInfo AnalysisCount(System.Xml.XmlReader reader)
        {
            ChannelSearchOutlineInfo channelSearchOutLineInfo = new ChannelSearchOutlineInfo();

            if (reader.ReadToFollowing("count"))
            {
                channelSearchOutLineInfo.Count = reader.ReadElementContentAsInt();
                if (reader.IsStartElement("page_count"))
                {
                    channelSearchOutLineInfo.PageCount = reader.ReadElementContentAsInt();
                    if (reader.IsStartElement("countInPage"))
                    {
                        channelSearchOutLineInfo.CountInPage = reader.ReadElementContentAsInt();
                        if (reader.IsStartElement("page"))
                        {
                            channelSearchOutLineInfo.CurrentPage = reader.ReadElementContentAsInt();
                            ///*
                            // * 总个数是否小于每页的个数,小于的话第一页返回总个数,其余页返回0
                            // * 不小于判断是哪页,其余页返回每页个数,最后一页算一下还剩下多少页
                            // */
                            //return count > countInPage ?
                            //    (pageIndex > pageCount ? 0 : (pageIndex == pageCount) ? count - (pageIndex - 1) * countInPage : countInPage) :
                            //    (pageIndex > 1 ? 0 : count);
                        }
                    }
                }
            }
            return(channelSearchOutLineInfo);
        }
Example #13
0
        public void ReadXml(XmlReader xmlReader)
        {
            while (xmlReader.ReadToFollowing("assembly"))
            {
                Name = xmlReader.GetAttribute("name");
                Version = xmlReader.GetAttribute("version");

                if (!xmlReader.IsEmptyElement)
                {
                    var childReader = xmlReader.ReadSubtree();

                    while (childReader.Read())
                    {
                        if (childReader.NodeType == XmlNodeType.Element)
                        {
                            if (childReader.Name == "type")
                            {
                                var type = new TypeInfo();
                                type.ReadXml(xmlReader);
                                Types.Add(type);
                            }
                        }
                    }
                }
            }
        }
Example #14
0
 //public static string HostAddress
 //{
 //    get
 //    {
 //        foreach (IPAddress address in Dns.GetHostAddresses (Dns.GetHostName ())) {
 //            if (address.AddressFamily == AddressFamily.InterNetwork) {
 //                return address;
 //            }
 //        }
 //    }
 //}
 public static Version DeserializeSpecVersion(XmlReader reader)
 {
     try {
         // We assume the elements appear in this order
         reader.ReadToFollowing ("major");
         reader.Read ();
         var major = reader.ReadContentAsInt ();
         reader.ReadToFollowing ("minor");
         reader.Read ();
         var minor = reader.ReadContentAsInt ();
         return new Version (major, minor);
     } catch (Exception e) {
         throw new UpnpDeserializationException ("There was a problem deserializing a spec version.", e);
     } finally {
         reader.Close ();
     }
 }
Example #15
0
 internal virtual void Load (XmlReader reader)
 {
         reader.ReadToFollowing (XmlName);
         while (reader.MoveToNextAttribute ()) {
                 LoadAttribute (reader.Name, reader.Value);
         }
         LoadValue (reader);
 }
Example #16
0
 private static IEnumerable<string> ReadMedia(XmlReader media)
 {
     while (media.ReadToFollowing("local"))
     {
         media.MoveToFirstAttribute();
         yield return media.ReadContentAsString();
     }
 }
Example #17
0
 // Gets the creation date of the Project Gutenberg catalog. This method should be called
 // before parsing the books and volumes because the creation date is at the beginning;
 // calling it later would not find the XML element with the date any more and would
 // continue reading the content to the end, skipping all content. This method expects a
 // reader returned by the method Open.
 public Date GetCreated(XmlReader reader)
 {
     Log.Verbose("Getting creation date...");
     if (!reader.ReadToFollowing("Description", RDF))
         throw new ApplicationException("Missing creation time.");
     if (!reader.ReadToDescendant("value", RDF))
         throw new ApplicationException("Missing creation date value.");
     return reader.ReadElementContentAsDate();
 }
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader == null) throw new ArgumentNullException("reader");

            if (!reader.ReadToFollowing("photos"))
                throw new ResponseXmlException("Unable to find \"photos\" element in response.");

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "maxdisplaypx":
                        MaximumDisplayPixels = reader.ReadContentAsInt();
                        break;
                    case "maxupload":
                        MaximumPhotoUpload = reader.ReadContentAsLong();
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            if (!reader.ReadToFollowing("videos"))
                throw new ResponseXmlException("Unable to find \"videos\" element in response.");

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "maxduration":
                        MaximumVideoDuration = reader.ReadContentAsInt();
                        break;
                    case "maxupload":
                        MaximumVideoUpload = reader.ReadContentAsLong();
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Skip();
        }
        //Attempt to read batch.xml to load previous settings
        //If anything goes wrong, just start without any preloaded settings
        public void ReadXml(XmlReader reader)
        {
            try
            {
                FileDescs = new Dictionary<string, FbxFileDesc>();

                reader.ReadToFollowing("BatchConversion");

                reader.ReadToDescendant("Output");
                OutputDir = reader.ReadElementContentAsString();

                while (reader.LocalName == "FbxFile")
                {
                    var newFile = new FbxFileDesc();

                    reader.ReadToDescendant("Filename");
                    var newFilename = reader.ReadElementContentAsString();

                    if (reader.LocalName != "CollisionGeneration")
                        reader.ReadToNextSibling("CollisionGeneration");

                    newFile.CollisionType = reader.ReadElementContentAsString();

                    while (reader.LocalName == "AnimClip")
                    {
                        var newClip = new AnimationClipDesc();

                        reader.ReadToDescendant("Name");
                        var newClipName = reader.ReadElementContentAsString();

                        if (reader.LocalName != "Keyframes")
                        reader.ReadToNextSibling("Keyframes");

                        newClip.BeginFrame = double.Parse(reader.GetAttribute("Begin"));
                        newClip.EndFrame = double.Parse(reader.GetAttribute("End"));
                        newClip.Fps = double.Parse(reader.GetAttribute("FPS"));

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

                        newFile.AnimationClips.Add(newClipName, newClip);
                    }

                    reader.ReadEndElement();
                    FileDescs.Add(newFilename, newFile);
                }
            }
            catch (Exception)
            {
                MessageBox.Show(ParentWindow, "Unable to read batch.xml, starting with a clean slate...",
                                "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                FileDescs = new Dictionary<string, FbxFileDesc>();
                OutputDir = "";
            }
        }
Example #20
0
 internal virtual void Load (XmlReader reader)
 {
         reader.ReadToFollowing (XmlName);
         FillLocation (reader);
         while (reader.MoveToNextAttribute ()) {
                 LoadAttribute (reader.Name, reader.Value);
         }
         reader.MoveToElement ();
         LoadValue (reader);
 }
Example #21
0
        protected T[] CreatFromXml <T>(System.Xml.XmlReader reader) where T : IGenericRecord
        {
            List <T> list = new List <T>();

            reader.ReadToFollowing("item");
            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                reader.ReadToFollowing("record");
                // reader stays on "record"
                T tempValue = default(T);
                //IGenericRecord tempValue = null;
                tempValue = CreateFromXml <T>(reader);
                if (tempValue != null)
                {
                    list.Add(tempValue);
                    reader.ReadEndElement();
                }
            }
            return(list.ToArray());
        }
Example #22
0
        public static List<Deficiency> ReadDeficiencies(XmlReader deficienciesReader)
        {
            List<Deficiency> deficiencyList = new List<Deficiency>();

            while (deficienciesReader.ReadToFollowing("Deficiency"))
            {
                deficiencyList.Add( ReadDeficiency(deficienciesReader.ReadSubtree()) );
            }

            return deficiencyList;
        }
 private static FaultCode Deserialize(XmlReader reader)
 {
     using (reader) {
         var code = new FaultCode ();
         reader.ReadToFollowing ("UPnPError", "urn:schemas-upnp-org:control-1-0");
         while (Helper.ReadToNextElement (reader)) {
             Deserialize (reader.ReadSubtree (), reader.Name, ref code);
         }
         return code;
     }
 }
Example #24
0
        internal static AttachedContact[] BuildList(XmlReader rdr)
        {
            List<AttachedContact> attachedContacts = new List<AttachedContact>();
            rdr.ReadStartElement("attached_communications");
            while (rdr.ReadToFollowing("attached_communication_id"))
            {
                attachedContacts.Add(new AttachedContact(rdr));
            }
            rdr.ReadEndElement();

            return attachedContacts.ToArray();
        }
 private static void ReadBandName(XmlReader reader, IDictionary<string, Band> bandsByName, Album album)
 {
     reader.ReadToFollowing("band");
     var bandName = reader.ReadElementContentAsString().Trim();
     if (!bandsByName.ContainsKey(bandName))
     {
         bandsByName[bandName] = new Band()
         {
             Name = bandName
         };
     }
     bandsByName[bandName].Albums.Add(album);
 }
Example #26
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            this.Clear();
            XmlSerializer x = new XmlSerializer(typeof(ExternalTool));

            while (reader.ReadToFollowing("ExternalTool"))
            {
                object o = x.Deserialize(reader);
                if (o is ExternalTool)
                {
                    this.Add(o);
                }
            }
        }
Example #27
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.ReadToFollowing(this.GetType().Name))
     {
         reader.ReadStartElement();
         if (reader.LocalName == typeof(TabLayout).Name || reader.LocalName == "MultiContent") // MultiContent is old name and is used here for compatibility with old saved layouts
         {
             DockedContent = new TabLayout(Root, reader.ReadSubtree());
             Content       = DockedContent;
             reader.ReadEndElement();
         }
         reader.ReadEndElement();
     }
 }
        /// <summary>
        /// Initializes a new instance of the Message class from data
        /// read from an XML stream.
        /// </summary>
        /// <param name="reader">The XmlReader for the XML data.</param>
        public Message(XmlReader reader)
        {
            MemoryStream growableBuffer = null;

            try
            {
                reader.ReadToFollowing("From");
                this.From = reader.ReadElementContentAsString();

                reader.ReadToFollowing("To");
                this.To = reader.ReadElementContentAsString();

                reader.ReadToFollowing("Body");
                int got = 0;
                byte[] buffer = new byte[100];
                growableBuffer = new MemoryStream();
                while ((got = reader.ReadElementContentAsBase64(buffer, 0, buffer.Length)) > 0)
                {
                    growableBuffer.Write(buffer, 0, got);
                }

                this.Body = growableBuffer.ToArray();

                this.Valid = true;
            }
            catch
            {
                return;
            }
            finally
            {
                if (growableBuffer != null)
                {
                    growableBuffer.Dispose();
                }
            }
        }
Example #29
0
 void IFlickrParsable.Load(XmlReader reader)
 {
     if (reader.LocalName != "count" && !reader.ReadToFollowing("count"))
     return;
       this.Count = reader.ReadElementContentAsInt();
       if (reader.LocalName != "prevphotos")
     reader.ReadToFollowing("prevphotos");
       reader.ReadToDescendant("photo");
       while (reader.LocalName == "photo")
       {
     FavoriteContextPhoto favoriteContextPhoto = new FavoriteContextPhoto();
     favoriteContextPhoto.Load(reader);
     this.PreviousPhotos.Add(favoriteContextPhoto);
       }
       if (reader.LocalName != "nextphotos")
     reader.ReadToFollowing("nextphotos");
       reader.ReadToDescendant("photo");
       while (reader.LocalName == "photo")
       {
     FavoriteContextPhoto favoriteContextPhoto = new FavoriteContextPhoto();
     favoriteContextPhoto.Load(reader);
     this.NextPhotos.Add(favoriteContextPhoto);
       }
 }
Example #30
0
 internal Company(XmlReader rdr)
 {
     rdr.ReadStartElement("company");
     this.Id = rdr.ReadElementContentAsInt("id", "");
     this.Name = rdr.ReadElementString("name");
     this.Notes = rdr.ReadElementString("notes");
     //Skipping Images
     rdr.ReadToFollowing("tags");
     this.Tags = Tag.BuildList(rdr);
     this.Locations = Location.BuildList(rdr);
     this.Comments = MegaComment.BuildList(rdr);
     this.CreatedAt = rdr.ReadElementString("created_at").FromBatchBookFormat();
     this.UpdatedAt = rdr.ReadElementString("updated_at").FromBatchBookFormat();
     rdr.ReadEndElement();
 }
Example #31
0
 public void DoSearch(string[] parts, ArrayList result, System.Xml.XmlReader reader, bool securityTrimmingEnabled)
 {
     if (reader.ReadToFollowing("category", ns) && reader.MoveToAttribute("name") && reader.Value == "Root" && reader.MoveToElement())
     {
         int i = 1;
         if (i < parts.Length)
         {
             ReadSubElements(reader, parts, i, result, securityTrimmingEnabled);
         }
         else
         {
             ReadSubItems(reader, result, securityTrimmingEnabled);
         }
     }
 }
Example #32
0
 public bool FromXml(XmlReader reader)
 {
     if (reader == null)
     {
         return false;
     }
     if (reader.Name == "Id" || reader.ReadToFollowing("Id"))
     {
         Id = reader.ReadElementContentAsString();
         Name = reader.ReadElementContentAsString();
         Memo = reader.ReadElementContentAsString();
         return true;
     }
     return false;
 }
		public void LoadAllDefinitions(XmlReader xmlReader)
		{
			LdmlDataMapper adaptor = CreateLdmlAdaptor();
			// Check the current node, it should be 'writingsystems'
			if ("writingsystems" == xmlReader.Name)
			{
				while (xmlReader.ReadToFollowing("ldml"))
				{
					var ws = (WritingSystemDefinition)CreateNew();
					adaptor.Read(xmlReader.ReadSubtree(), ws);
					ws.StoreID = ws.Bcp47Tag;
					Set(ws);
				}

			}
		}
Example #34
0
 public bool FromXml(XmlReader reader)
 {
     if (reader == null)
     {
         return false;
     }
     if (reader.Name == "Type" || reader.ReadToFollowing("Type"))
     {
         Type = reader.ReadElementContentAsInt();
         Name = reader.ReadElementContentAsString();
         Data = reader.ReadElementContentAsString();
         Memo = reader.ReadElementContentAsString();
         return true;
     }
     return false;
 }
Example #35
0
		public void ReadXml(XmlReader reader) {
			reader.ReadToFollowing("TypeName");
			reader.ReadStartElement("TypeName");
			TypeName=reader.ReadString();
			reader.ReadEndElement();//TypeName
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();//gets rid of whitespace if in debug mode.
			}
			reader.ReadStartElement("Obj");
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();
			}
			string strObj=reader.ReadOuterXml();
			//now get the reader to the correct location
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//Obj
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//DtoObject
			Type type=null;
			if(TypeName.StartsWith("List<")) {
				Type typeGen=Type.GetType(TypeName.Substring(5,TypeName.Length-6));
				Type typeList=typeof(List<>);
				type=typeList.MakeGenericType(typeGen);
			}
			else if(TypeName=="System.Drawing.Color") {
				type=typeof(int);
			}
			else {
				//This works fine for non-system types as well without specifying the assembly,
				//because we are already in the OpenDentBusiness assembly.
				type=Type.GetType(TypeName);
			}
			XmlSerializer serializer = new XmlSerializer(type);
			//XmlReader reader2=XmlReader.Create(new StringReader(strObj));
			XmlTextReader reader2=new XmlTextReader(new StringReader(strObj));
			if(TypeName=="System.Drawing.Color") {
				Obj=Color.FromArgb((int)serializer.Deserialize(reader2));
			}
			else {
				Obj=serializer.Deserialize(reader2);
			}
				//Convert.ChangeType(serializer.Deserialize(reader2),type);
		}
 private void ParseBlock(ref List<MemoryBlock> list, ref XmlReader reader)
 {
     MemoryBlock MemBlock = new MemoryBlock();
     reader.ReadToFollowing("m_block_base_addr");
     MemBlock.BlockAddress = (UInt64)reader.ReadElementContentAs(typeof(UInt64), null);
     reader.ReadToNextSibling("protection");
     MemBlock.BlockProtection = (UInt32)reader.ReadElementContentAs(typeof(UInt32), null);
     reader.ReadToNextSibling("m_size");
     MemBlock.BlockSize = (UInt64)reader.ReadElementContentAs(typeof(UInt64), null);
     reader.ReadToNextSibling("m_storage_type");
     MemBlock.BlockStorageType = (UInt32)reader.ReadElementContentAs(typeof(UInt32), null);
     reader.ReadToNextSibling("m_is_shared");
     MemBlock.IsShared = (Boolean)reader.ReadElementContentAs(typeof(Boolean), null);
     reader.ReadToNextSibling("m_map_file_name");
     MemBlock.MappedFileName = (String)reader.ReadElementContentAs(typeof(String), null);
     list.Add(MemBlock);
 }
        private ConnectionSetup readConnectionSetup(XmlReader reader)
        {
            ConnectionSetup connnectionSetup = null;

            if (reader.ReadToFollowing("ConnectionSetup"))
            {
                string serverName = reader.GetAttribute("serverName");
                bool windowsAuthentication = bool.Parse(reader.GetAttribute("windowsAuthentication"));
                string userName = reader.GetAttribute("userName");
                string password = reader.GetAttribute("password");
                int timeout = int.Parse(reader.GetAttribute("timeout"));

                connnectionSetup = new ConnectionSetup(serverName, userName, password, windowsAuthentication, timeout);
            }

            return connnectionSetup;
        }
Example #38
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     XmlUtilities.GetTypePropertyDic(GetType(), ref _propertyTypeDic, ref _propertyInfoDic);
     // reader stays on record
     reader.ReadToFollowing("param-list");
     try
     {
         reader.Read();
         while (reader.IsStartElement())
         {
             ReadProperty(reader);
         } // while
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #39
0
    public static List<SAMAlignedItem> ReadFrom(XmlReader source)
    {
      var result = new List<SAMAlignedItem>();

      source.ReadToFollowing("queries");
      if (source.ReadToDescendant("query"))
      {
        do
        {
          var query = new SAMAlignedItem();
          result.Add(query);

          query.Qname = source.GetAttribute("name");
          query.Sequence = source.GetAttribute("sequence");
          query.QueryCount = int.Parse(source.GetAttribute("count"));
          query.Sample = source.GetAttribute("sample");
          if (source.ReadToDescendant("location"))
          {
            do
            {
              var loc = new SAMAlignedLocation(query);

              loc.Seqname = source.GetAttribute("seqname");
              loc.Start = long.Parse(source.GetAttribute("start"));
              loc.End = long.Parse(source.GetAttribute("end"));
              loc.Strand = source.GetAttribute("strand")[0];
              loc.Cigar = source.GetAttribute("cigar");
              loc.AlignmentScore = int.Parse(source.GetAttribute("score"));
              loc.MismatchPositions = source.GetAttribute("mdz");
              loc.NumberOfMismatch = int.Parse(source.GetAttribute("nmi"));
              var nnmpattr = source.GetAttribute("nnpm");
              if (nnmpattr != null)
              {
                loc.NumberOfNoPenaltyMutation = int.Parse(nnmpattr);
              }
            } while (source.ReadToNextSibling("location"));
          }
        } while (source.ReadToNextSibling("query"));
      }

      return result;
    }
Example #40
0
		public void ReadXml(XmlReader reader) {
			reader.ReadToFollowing("TypeName");
			reader.ReadStartElement("TypeName");
			TypeName=reader.ReadString();
			reader.ReadEndElement();//TypeName
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();//gets rid of whitespace if in debug mode.
			}
			reader.ReadStartElement("Obj");
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();
			}
			string strObj=reader.ReadOuterXml();
			//now get the reader to the correct location
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//Obj
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//DtoObject
			//Now, process what we read.
			Type type=null;
			if(TypeName=="System.Drawing.Color") {
				type=typeof(int);
			}
			else{
				type=ConvertNameToType(TypeName);
			}
			XmlSerializer serializer = new XmlSerializer(type);
			//XmlReader reader2=XmlReader.Create(new StringReader(strObj));
			XmlTextReader reader2=new XmlTextReader(new StringReader(strObj));
			if(TypeName=="System.Drawing.Color") {
				Obj=Color.FromArgb((int)serializer.Deserialize(reader2));
			}
			else {
				Obj=serializer.Deserialize(reader2);
			}
				//Convert.ChangeType(serializer.Deserialize(reader2),type);
		}
Example #41
0
        public static string[] GetFiles(string path, string searchPattern)
        {
            string[]      m_arExt       = searchPattern.Split(';');
            List <string> strFiles      = new List <string>();
            List <string> strValidFiles = new List <string>();

            foreach (string filter in m_arExt)
            {
                strFiles.AddRange(System.IO.Directory.GetFiles(path, filter));
            }

            foreach (string fileName in strFiles)
            {
                using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(fileName))
                {
                    try
                    {
                        while (reader.ReadToFollowing("Template"))
                        {
                            string name = reader.GetAttribute("Name");

                            if (string.IsNullOrEmpty(name) == false)
                            {
                                strValidFiles.Add(fileName);
                            }
                        }
                    }
                    catch
                    {
                        Logger.Log("The template file [ " + fileName + " ] cannot be read.");
                    }
                }
            }

            return(strValidFiles.ToArray());
        }
Example #42
0
 public override bool ReadToFollowing(string name)
 {
     CheckAsync();
     return(_coreReader.ReadToFollowing(name));
 }
Example #43
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.ReadToFollowing(this.GetType().Name))
            {
                String s = reader.GetAttribute(Orientation.GetType().Name);
                m_orientation = (Orientation)(Enum.Parse(Orientation.GetType(), s));
                switch (m_orientation)
                {
                case Orientation.Horizontal:
                    if (reader.ReadToDescendant("Column"))
                    {
                        RowDefinitions.Add(NewRowDefinition(new GridLength(1, GridUnitType.Star), m_minGridSize.Height));
                        do
                        {
                            double      width  = double.Parse(reader.GetAttribute("Width"));
                            IDockLayout layout = null;
                            reader.ReadStartElement();
                            if (reader.LocalName == typeof(DockedWindow).Name)
                            {
                                DockedWindow dockedWindow = new DockedWindow(Root, reader.ReadSubtree());
                                layout = dockedWindow.DockedContent.Children.Count != 0 ? dockedWindow : null;
                                reader.ReadEndElement();
                            }
                            else if (reader.LocalName == typeof(GridLayout).Name)
                            {
                                GridLayout gridLayout = new GridLayout(Root, reader.ReadSubtree());
                                layout = gridLayout.Layouts.Count > 0 ? gridLayout : null;
                                reader.ReadEndElement();
                            }
                            if (layout != null)
                            {
                                if (Children.Count > 0)
                                {
                                    ColumnDefinitions.Add(NewColumnDefinition(new GridLength(1, GridUnitType.Auto), 0));
                                    Children.Add(NewGridSplitter(Orientation));
                                }
                                ColumnDefinitions.Add(NewColumnDefinition(new GridLength(width, GridUnitType.Star), m_minGridSize.Width));
                                m_children.Add(layout);
                                Children.Add((FrameworkElement)layout);
                            }
                        } while (reader.ReadToNextSibling("Column"));
                    }
                    break;

                case Orientation.Vertical:
                    if (reader.ReadToDescendant("Row"))
                    {
                        ColumnDefinitions.Add(NewColumnDefinition(new GridLength(1, GridUnitType.Star), m_minGridSize.Width));
                        do
                        {
                            double      height = double.Parse(reader.GetAttribute("Height"));
                            IDockLayout layout = null;
                            reader.ReadStartElement();
                            if (reader.LocalName == typeof(DockedWindow).Name)
                            {
                                DockedWindow dockedWindow = new DockedWindow(Root, reader.ReadSubtree());
                                layout = dockedWindow.DockedContent.Children.Count != 0 ? dockedWindow : null;
                                reader.ReadEndElement();
                            }
                            else if (reader.LocalName == typeof(GridLayout).Name)
                            {
                                GridLayout gridLayout = new GridLayout(Root, reader.ReadSubtree());
                                layout = gridLayout.Layouts.Count > 0 ? gridLayout : null;
                                reader.ReadEndElement();
                            }
                            if (layout != null)
                            {
                                if (Children.Count > 0)
                                {
                                    RowDefinitions.Add(NewRowDefinition(new GridLength(1, GridUnitType.Auto), 0));
                                    Children.Add(NewGridSplitter(Orientation));
                                }
                                RowDefinitions.Add(NewRowDefinition(new GridLength(height, GridUnitType.Star), m_minGridSize.Height));
                                m_children.Add(layout);
                                Children.Add((FrameworkElement)layout);
                            }
                        } while (reader.ReadToNextSibling("Row"));
                    }
                    break;
                }
                for (int i = 0; i < Children.Count; i++)
                {
                    Grid.SetColumn(Children[i], Orientation == Orientation.Horizontal ? i : 0);
                    Grid.SetRow(Children[i], Orientation == Orientation.Vertical ? i : 0);
                }
                reader.ReadEndElement();
            }
        }
Example #44
0
        protected override Object AnalysisData(System.Xml.XmlReader reader)
        {
            PlayInfos = new Dictionary <int, PlayInfo>(6);

            double totalDuraiton = 0;

            if (reader.ReadToFollowing("channel"))
            {
                totalDuraiton = double.Parse(reader["dur"]);
                while (reader.Read())
                {
                    if (reader.Name == "file" &&
                        reader.NodeType == XmlNodeType.Element)
                    {
                        reader.Read();
                        while (reader.IsStartElement("item"))
                        {
                            var info = new PlayInfo();
                            if (IsDrag)
                            {
                                info.Segments = new List <PlaySegmentInfo>();
                            }
                            var bitrate = reader.GetAttribute("bitrate");
                            var ft      = reader.GetAttribute("ft");
                            if (bitrate == null || ft == null)
                            {
                                continue;
                            }
                            info.Bitrate       = Convert.ToInt32(bitrate);
                            info.ft            = Convert.ToInt32(ft);
                            info.Rid           = reader.GetAttribute("rid");
                            info.TotalDuration = totalDuraiton;
                            PlayInfos.Add(info.ft, info);
                            reader.ReadToNextSibling("item");
                        }
                    }

                    if (reader.Name == "dt" &&
                        reader.NodeType == XmlNodeType.Element)
                    {
                        var ft = Convert.ToInt32(reader.GetAttribute("ft"));
                        if (PlayInfos.ContainsKey(ft))
                        {
                            var info = PlayInfos[ft];
                            reader.ReadToFollowing("sh");
                            reader.Read();
                            info.Sh = reader.Value;
                            reader.ReadToFollowing("st");
                            reader.Read();
                            var st = reader.Value;
                            var ci = new CultureInfo("en-US");
                            info.St = DateTime.ParseExact(st, "ddd MMM dd HH:mm:ss yyyy UTC", ci);
                            reader.ReadToFollowing("bwt");
                            reader.Read();
                            info.Bwt = Convert.ToInt32(reader.Value);
                        }
                    }

                    if (reader.Name == "drag" &&
                        reader.NodeType == XmlNodeType.Element)
                    {
                        var ft = Convert.ToInt32(reader.GetAttribute("ft"));
                        if (PlayInfos.ContainsKey(ft))
                        {
                            reader.Read();
                            var    info      = PlayInfos[ft];
                            double timestamp = 0;
                            while (reader.IsStartElement("sgm"))
                            {
                                var segment = new PlaySegmentInfo();
                                segment.No            = int.Parse(reader["no"]);
                                segment.Duration      = double.Parse(reader["dur"]);
                                segment.FileSize      = ulong.Parse(reader["fs"]);
                                segment.HeadLength    = ulong.Parse(reader["hl"]);
                                timestamp            += segment.Duration;
                                segment.TotalDuration = timestamp;
                                info.Segments.Add(segment);
                                reader.ReadToNextSibling("sgm");
                            }
                        }
                    }
                }
            }

            return(1);
        }
Example #45
0
        public DataTable GetProjectTable(string subFolder)
        {
            DataTable table = new DataTable();

            table.Columns.Add(new DataColumn("TemplateName", System.Type.GetType("System.String")));
            table.Columns.Add(new DataColumn("TemplateDescription", System.Type.GetType("System.String")));
            table.Columns.Add(new DataColumn("TemplatePath", System.Type.GetType("System.String")));
            table.Columns.Add(new DataColumn("TemplateCreateDate", System.Type.GetType("System.String")));

            table.Columns.Add(new DataColumn("Name", System.Type.GetType("System.String")));
            table.Columns.Add(new DataColumn("Location", System.Type.GetType("System.String")));
            table.Columns.Add(new DataColumn("Description", System.Type.GetType("System.String")));
            table.Columns.Add(new DataColumn("EpiVersion", System.Type.GetType("System.String")));
            table.Columns.Add(new DataColumn("CreateDate", System.Type.GetType("System.String")));
            DataRow row;

            string projectFolderPath = Path.Combine(templatesPath, subFolder);

            if (Directory.Exists(projectFolderPath) != true)
            {
                return(table);
            }

            String[] projectTemplates = GetFiles(projectFolderPath, "*.xml;*.eit");

            foreach (string path in projectTemplates)
            {
                row = table.NewRow();

                try
                {
                    using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(path))
                    {
                        while (reader.ReadToFollowing("Template"))
                        {
                            if (reader.MoveToFirstAttribute())
                            {
                                AddAttributeToProjectTableRow(row, reader);

                                while (reader.MoveToNextAttribute())
                                {
                                    AddAttributeToProjectTableRow(row, reader);
                                }

                                while (reader.ReadToFollowing("Project"))
                                {
                                    if (reader.MoveToFirstAttribute())
                                    {
                                        if (table.Columns.Contains(reader.Name))
                                        {
                                            row[reader.Name] = reader.Value;
                                        }

                                        while (reader.MoveToNextAttribute())
                                        {
                                            if (table.Columns.Contains(reader.Name))
                                            {
                                                row[reader.Name] = reader.Value;
                                            }
                                        }
                                    }
                                }

                                row["TemplatePath"] = path;
                                table.Rows.Add(row);
                            }
                        }
                    }
                }
                catch {}
            }

            return(table);
        }