System.Xml.XmlReader.Read()

Here are the examples of the csharp api System.Xml.XmlReader.Read() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

741 Examples 7

19 View Source File : LocalInstanceSourceSettings.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public override void ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
                return;

            while (reader.Read() &&
                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == GetType().Name))
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case nameof(InstanceRefList):
                            if (reader["Key"] == nameof(ConnectingInstanceList))
                                ConnectingInstanceList.ReadXml(reader);
                            break;

                        case nameof(InstanceSourceSettingsBase):
                            base.ReadXml(reader);
                            break;
                    }
                }
            }
        }

19 View Source File : XmlExtensionReader.cs
License : GNU General Public License v3.0
Project Creator : AndreiFedarets

private ExtensionDefinition ReadExtension(XmlReader reader, string baseDirectory)
        {
            //Move to <Extension> element
            MoveToElement(reader, ExtensionElementName);

            //Prepare Extension properties
            Guid uid = Guid.Empty;
            List<ProfilingTypeDefinition> profilingTypes = new List<ProfilingTypeDefinition>();
            List<ProfilingTargetDefinition> profilingTargets = new List<ProfilingTargetDefinition>();
            List<FrameworkDefinition> frameworks = new List<FrameworkDefinition>();
            List<ProductivityDefinition> productivities = new List<ProductivityDefinition>();
            List<ApplicationExtensionDefinition> applicationExtensions = new List<ApplicationExtensionDefinition>();
            List<LocalizationDefinition> localizations = new List<LocalizationDefinition>();
            List<AttachmentDefinition> attachments = new List<AttachmentDefinition>();

            //Read Extension attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                    case UidAttributeName:
                        uid = reader.ReadContentAsGuid();
                        break;
                }
            }

            //Move back to <Extension> element
            reader.MoveToElement();

            //Read <Extension> element content
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement &&
                    string.Equals(ExtensionElementName, reader.Name))
                {
                    break;
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (reader.Name)
                {
                    case ProfilingTypeElementName:
                        ProfilingTypeDefinition profilingType = ReadProfilingType(reader, baseDirectory);
                        profilingTypes.Add(profilingType);
                        break;
                    case ProfilingTargetElementName:
                        ProfilingTargetDefinition profilingTarget = ReadProfilingTarget(reader, baseDirectory);
                        profilingTargets.Add(profilingTarget);
                        break;
                    case FrameworkElementName:
                        FrameworkDefinition framework = ReadFramework(reader, baseDirectory);
                        frameworks.Add(framework);
                        break;
                    case ProductivityElementName:
                        ProductivityDefinition productivity = ReadProductivity(reader, baseDirectory);
                        productivities.Add(productivity);
                        break;
                    case ApplicationExtensionElementName:
                        ApplicationExtensionDefinition applicationExtension = ReadApplicationExtension(reader, baseDirectory);
                        applicationExtensions.Add(applicationExtension);
                        break;
                    case LocalizationElementName:
                        LocalizationDefinition localization = ReadLocalization(reader);
                        localizations.Add(localization);
                        break;
                    case AttachmentElementName:
                        AttachmentDefinition attachment = ReadAttachment(reader, baseDirectory);
                        attachments.Add(attachment);
                        break;
                }
            }
            ExtensionDefinition extensionDefinition = new ExtensionDefinition(uid, baseDirectory, profilingTypes, profilingTargets, frameworks, productivities, applicationExtensions, attachments, localizations);
            return extensionDefinition;
        }

19 View Source File : DrawingParser.cs
License : MIT License
Project Creator : ahopper

private static Brush? ParseBrush(XmlReader reader)
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "LinearGradientBrush": return ParseLinearGradientBrush(reader);
                    }
                }
            }
            return null;
        }

19 View Source File : MinisignPublicKeyDictionary.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
                return;

            while (reader.Read() &&
                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == GetType().Name))
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "PublicKey")
                {
                    while (reader.Read() &&
                        !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "PublicKey"))
                        if (reader.NodeType == XmlNodeType.Text)
                            Add(reader.Value);
                }
            }
        }

19 View Source File : MainViewModel.cs
License : MIT License
Project Creator : ahopper

private void loadIcons(Stream stream, IList<IconVM> output)
        {
            using (XmlReader reader = XmlReader.Create(stream))
            {
                reader.MoveToContent();
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name == "GeometryDrawing" || reader.Name == "DrawingGroup")
                        {
                            var src = reader.ReadOuterXml();
                            output.Add(new IconVM(src));
                        }
                    }
                }
            }
        }

19 View Source File : XmlHelper.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public static string ReadXmlText(XmlReader xr)
        {
            try
            {
                xr.Read() ;
                return xr.ReadContentreplacedtring().Trim() ;
            }
            catch
            {
                return null ;
            }
        }

19 View Source File : ServerListTests.cs
License : GNU General Public License v3.0
Project Creator : Amebis

[TestMethod()]
        public void ServersNetworkTest()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;

            var xmlReader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(@"<ResourceRef Uri=""https://disco.eduvpn.org/v2/server_list.json"">
						<MinisignPublicKeyDictionary Key=""PublicKeys"">
							<PublicKey>RWRtBSX1alxyGX+Xn3LuZnWUT0w//B6EmTJvgaAxBMYzlQeI+jdrO6KF</PublicKey>
							<PublicKey>RWQKqtqvd0R7rUDp0rWzbtYPA3towPWcLDCl7eY9pBMMI/ohCmrS0WiM</PublicKey>
						</MinisignPublicKeyDictionary>
					</ResourceRef>")));
            while (xmlReader.ReadState == ReadState.Initial)
                xmlReader.Read();
            var source = new ResourceRef();
            source.ReadXml(xmlReader);

            // Load list of servers.
            var server_list_list_json = Xml.Response.Get(source);
            var server_list_list_ia = new ServerDictionary();
            server_list_list_ia.LoadJSON(server_list_list_json.Value);

            // Load all servers APIs.
            Parallel.ForEach(server_list_list_ia.Values, srv =>
            {
                var uriBuilder = new UriBuilder(srv.Base);
                uriBuilder.Path += "info.json";
                try
                {
                    new Models.ServerEndpoints().LoadJSON(Xml.Response.Get(uriBuilder.Uri).Value);
                }
                catch (AggregateException ex)
                {
                    if (ex.InnerException is WebException ex_web &&
                        (ex_web.Status == WebExceptionStatus.ConnectFailure || // connection refused
                        ex_web.Status == WebExceptionStatus.TrustFailure || // expired or invalid server certificate
                        ex_web.Status == WebExceptionStatus.SecureChannelFailure || // TLS failure
                        ex_web.Status == WebExceptionStatus.Timeout)) // server down
                    {
                        // Ignore connection failure WebException(s), as some servers are not publicly available or have other issues.
                    }
                    else
                        throw;
                }
            });

            // Re-load list of servers.
            server_list_list_json = Xml.Response.Get(
                res: source,
                previous: server_list_list_json);
        }

19 View Source File : Identity.cs
License : MIT License
Project Creator : actions

internal static KeyValueOfStringString FromXml(IServiceProvider serviceProvider, XmlReader reader)
        {
            KeyValueOfStringString obj = new KeyValueOfStringString();
            Debug.replacedert(reader.NodeType == XmlNodeType.Element, "Expected a node.");

            bool empty = reader.IsEmptyElement;

            // Process the xml attributes
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    switch (reader.Name)
                    {
                        default:
                            // Allow attributes such as xsi:type to fall through
                            break;
                    }
                }
            }

            // Process the fields in Xml elements
            reader.Read();
            if (!empty)
            {
                while (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "Key":
                            obj.Key = XmlUtility.StringFromXmlElement(reader);
                            break;
                        case "Value":
                            obj.Value = XmlUtility.StringFromXmlElement(reader);
                            break;
                        default:
                            // Make sure that we ignore XML node trees we do not understand
                            reader.ReadOuterXml();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            return obj;
        }

19 View Source File : XmlExtensionReader.cs
License : GNU General Public License v3.0
Project Creator : AndreiFedarets

private FrameworkDefinition ReadFramework(XmlReader reader, string baseDirectory)
        {
            //Move to <Framework> element
            MoveToElement(reader, FrameworkElementName);

            //Prepare Framework properties
            Guid uid = Guid.Empty;
            List<ExportDefinition> exports = new List<ExportDefinition>();
            List<LocalizationDefinition> localizations = new List<LocalizationDefinition>();
            List<AttributeDefinition> attributes = new List<AttributeDefinition>();
            List<PrerequisiteDefinition> prerequisites = new List<PrerequisiteDefinition>();

            //Read Framework attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                    case UidAttributeName:
                        uid = reader.ReadContentAsGuid();
                        break;
                }
            }

            //Move back to <Framework> element
            reader.MoveToElement();

            //Read <Framework> element content
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement &&
                    string.Equals(FrameworkElementName, reader.Name))
                {
                    break;
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (reader.Name)
                {
                    case ExportElementName:
                        ExportDefinition export = ReadExport(reader, baseDirectory);
                        exports.Add(export);
                        break;
                    case LocalizationElementName:
                        LocalizationDefinition localization = ReadLocalization(reader);
                        localizations.Add(localization);
                        break;
                    case AttributeElementName:
                        AttributeDefinition attribute = ReadAttribute(reader);
                        attributes.Add(attribute);
                        break;
                    case PrerequisiteElementName:
                        PrerequisiteDefinition prerequisite = ReadPrerequisite(reader, baseDirectory);
                        prerequisites.Add(prerequisite);
                        break;
                }
            }

            FrameworkDefinition definition = new FrameworkDefinition(uid, exports, localizations, attributes, prerequisites);
            return definition;
        }

19 View Source File : AccessMapping.cs
License : MIT License
Project Creator : actions

internal static AccessMapping FromXml(IServiceProvider serviceProvider, XmlReader reader)
        {
            AccessMapping obj = new AccessMapping();
            Debug.replacedert(reader.NodeType == XmlNodeType.Element, "Expected a node.");

            Boolean empty = reader.IsEmptyElement;

            // Process the xml attributes
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    switch (reader.Name)
                    {
                        case "AccessPoint":
                            obj.AccessPoint = reader.Value;
                            break;
                        case "DisplayName":
                            obj.DisplayName = reader.Value;
                            break;
                        case "Moniker":
                            obj.Moniker = reader.Value;
                            break;
                        default:
                            // Allow attributes such as xsi:type to fall through
                            break;
                    }
                }
            }

            // Process the fields in Xml elements
            reader.Read();
            if (!empty)
            {
                while (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        default:
                            // Make sure that we ignore XML node trees we do not understand
                            reader.ReadOuterXml();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            return obj;
        }

19 View Source File : SerializableStringDictionary.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
                return;

            while (reader.Read() &&
                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == GetType().Name))
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "DictionaryEntry")
                {
                    var key = reader["Key"];
                    if (key == null)
                        throw new FormatException();

                    var value = reader["Value"];
                    this[key] = value;
                }
            }
        }

19 View Source File : XmlResponseParser.cs
License : Apache License 2.0
Project Creator : aloneguid

public IReadOnlyCollection<IOEntry> ParseListObjectV2Response(string xml, out string continuationToken)
      {
         continuationToken = null;
         var result = new List<IOEntry>();
         using(var sr = new StringReader(xml))
         {
            using(var xr = XmlReader.Create(sr))
            {
               string en = null;

               while(xr.Read())
               {
                  if(xr.NodeType == XmlNodeType.Element)
                  {
                     switch(xr.Name)
                     {
                        case "Contents":
                           string key = null;
                           string lastMod = null;
                           string eTag = null;
                           string size = null;
                           string storageClreplaced = null;
                           // read all the elements in this
                           while(xr.Read() && !(xr.NodeType == XmlNodeType.EndElement && xr.Name == "Contents"))
                           {
                              if(xr.NodeType == XmlNodeType.Element)
                                 en = xr.Name;
                              else if(xr.NodeType == XmlNodeType.Text)
                              {
                                 switch(en)
                                 {
                                    case "Key":
                                       key = xr.Value;
                                       break;
                                    case "LastModified":
                                       lastMod = xr.Value;
                                       break;
                                    case "ETag":
                                       eTag = xr.Value;
                                       break;
                                    case "Size":
                                       size = xr.Value;
                                       break;
                                    case "StorageClreplaced":
                                       storageClreplaced = xr.Value;
                                       break;
                                 }
                              }
                           }

                           if(key != null)
                           {
                              var entry = new IOEntry(key)
                              {
                                 LastModificationTime = DateTimeOffset.Parse(lastMod),
                                 Size = int.Parse(size)
                              };
                              entry.TryAddProperties(
                                 "ETag", eTag,
                                 "StorageClreplaced", storageClreplaced);
                              result.Add(entry);
                           }

                           break;
                        case "CommonPrefixes":
                           while(xr.Read() && !(xr.NodeType == XmlNodeType.EndElement && xr.Name == "CommonPrefixes"))
                           {
                              // <Prefix>foldername/</Prefix>
                              if(xr.NodeType == XmlNodeType.Element)
                                 en = xr.Name;
                              else if(xr.NodeType == XmlNodeType.Text)
                              {
                                 if(en == "Prefix")
                                 {
                                    result.Add(new IOEntry(xr.Value));
                                 }
                              }
                           }
                           break;
                        case "NextContinuationToken":
                           throw new NotImplementedException();
                     }
                  }
               }
            }
         }

         return result;
      }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : AdvancedHacker101

public void loadXML(string xmlfile)
        {
            if (File.Exists(xmlfile))
            {
                using (XmlReader xml = XmlReader.Create(xmlfile))
                {

                    while (xml.Read())
                    {
                        if (xml.IsStartElement())
                        {
                            if (xml.Name == "drop")
                            {
                                blackList.Add(xml.GetAttribute("hostname"));
                            }
                            else if (xml.Name == "redirect")
                            {
                                redirect.Add(xml.GetAttribute("from") + ":" + xml.GetAttribute("to"));
                            }
                        }
                    }

                    Console.WriteLine("Configuration Loaded!");
                }
            }
            else throw new FileNotFoundException("Failed to load test.xml configuration file.\nPlease place it in the same directory as the dnsServer.exe file");
        }

19 View Source File : InstanceRefList.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
                return;

            while (reader.Read() &&
                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == GetType().Name))
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == nameof(InstanceRef))
                {
                    var el = new InstanceRef();
                    el.ReadXml(reader);
                    Add(el);
                }
            }
        }

19 View Source File : LocationMapping.cs
License : MIT License
Project Creator : actions

internal static LocationMapping FromXml(IServiceProvider serviceProvider, XmlReader reader)
        {
            LocationMapping obj = new LocationMapping();
            Debug.replacedert(reader.NodeType == XmlNodeType.Element, "Expected a node.");

            Boolean empty = reader.IsEmptyElement;

            // Process the xml attributes
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    switch (reader.Name)
                    {
                        case "accessMappingMoniker":
                            obj.AccessMappingMoniker = reader.Value;
                            break;
                        case "location":
                            obj.Location = reader.Value;
                            break;
                        default:
                            // Allow attributes such as xsi:type to fall through
                            break;
                    }
                }
            }

            // Process the fields in Xml elements
            reader.Read();
            if (!empty)
            {
                while (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        default:
                            // Make sure that we ignore XML node trees we do not understand
                            reader.ReadOuterXml();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            return obj;
        }

19 View Source File : ResourceRef.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void ReadXml(XmlReader reader)
        {
            string v;

            Uri = !string.IsNullOrWhiteSpace(v = reader[nameof(Uri)]) ? new Uri(replacedemblyUri, v) : null;

            if (reader.IsEmptyElement)
                return;

            while (reader.Read() &&
                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == GetType().Name))
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == nameof(MinisignPublicKeyDictionary))
                {
                    if (reader["Key"] == nameof(PublicKeys))
                    {
                        PublicKeys = new MinisignPublicKeyDictionary();
                        PublicKeys.ReadXml(reader);
                    }
                }
            }
        }

19 View Source File : DrawingParser.cs
License : MIT License
Project Creator : ahopper

private static GeometryDrawing ParseGeometryDrawing(XmlReader reader)
        {
            GeometryDrawing drawing = new GeometryDrawing();
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                    case "Brush": drawing.Brush = Brush.Parse(reader.Value); break;
                    case "Geometry": drawing.Geometry = Geometry.Parse(reader.Value); break;
                }
            }
            reader.MoveToElement();
            reader = reader.ReadSubtree();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "GeometryDrawing.Geometry": drawing.Geometry = ParseGeometry(reader.ReadSubtree()); break;
                        case "GeometryDrawing.Brush": drawing.Brush = ParseBrush(reader.ReadSubtree()); break;
                    }
                }
            }
            return drawing;
        }

19 View Source File : XmlLayoutReader.cs
License : GNU General Public License v3.0
Project Creator : AndreiFedarets

private Menu ReadMenu(XmlReader reader, IContainer container)
        {
            //Move to <Menu> element
            MoveToElement(reader, MenuElementName);

            string id = string.Empty;
            Type controlHandlerType = typeof(MenuControlHandlerDefault);

            //Read <Menu> attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                    case IdAttributeName:
                        id = reader.ReadContentreplacedtring();
                        break;
                    case TypeAttributeName:
                        string type = reader.ReadContentreplacedtring();
                        controlHandlerType = Type.GetType(type);
                        break;
                }
            }

            Menu control = new Menu(id);

            IMenuControlHandler controlHandler = new MenuControlHandlerLazy(controlHandlerType, container);
            control.AttachHandler(controlHandler);

            //Read <Menu> element content
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement && string.Equals(MenuElementName, reader.Name))
                {
                    break;
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (reader.Name)
                {
                    case MenuItemElementName:
                        MenuItem menuItem = ReadMenuItem(reader, container);
                        control.Add(menuItem);
                        break;
                }
            }

            return control;
        }

19 View Source File : V2Loader.cs
License : MIT License
Project Creator : Abdesol

public static XshdSyntaxDefinition LoadDefinition(XmlReader reader, bool skipValidation)
		{
			reader = HighlightingLoader.GetValidatingReader(reader, true, skipValidation ? null : SchemaSet);
			reader.Read();
			return ParseDefinition(reader);
		}

19 View Source File : XmlExtensionReader.cs
License : GNU General Public License v3.0
Project Creator : AndreiFedarets

private ProfilingTypeDefinition ReadProfilingType(XmlReader reader, string baseDirectory)
        {
            //Move to <ProfilingType> element
            MoveToElement(reader, ProfilingTypeElementName);

            //Prepare ProfilingType properties
            Guid uid = Guid.Empty;
            Guid frameworkUid = Guid.Empty;
            bool isHidden = false;
            List<ExportDefinition> exports = new List<ExportDefinition>();
            List<DependencyDefinition> dependencies = new List<DependencyDefinition>();
            List<LocalizationDefinition> localizations = new List<LocalizationDefinition>();
            List<AttributeDefinition> attributes = new List<AttributeDefinition>();
            List<PrerequisiteDefinition> prerequisites = new List<PrerequisiteDefinition>();

            //Read ProfilingType attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                    case UidAttributeName:
                        uid = reader.ReadContentAsGuid();
                        break;
                    case FrameworkUidAttributeName:
                        frameworkUid = reader.ReadContentAsGuid();
                        break;
                    case HiddendAttributeName:
                        isHidden = reader.ReadContentAsBoolean();
                        break;
                }
            }

            //Move back to <ProfilingType> element
            reader.MoveToElement();

            //Read <ProfilingType> element content
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement &&
                    string.Equals(ProfilingTypeElementName, reader.Name))
                {
                    break;
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (reader.Name)
                {
                    case ExportElementName:
                        ExportDefinition export = ReadExport(reader, baseDirectory);
                        exports.Add(export);
                        break;
                    case DependencyElementName:
                        DependencyDefinition dependency = ReadDependency(reader);
                        dependencies.Add(dependency);
                        break;
                    case LocalizationElementName:
                        LocalizationDefinition localization = ReadLocalization(reader);
                        localizations.Add(localization);
                        break;
                    case AttributeElementName:
                        AttributeDefinition attribute = ReadAttribute(reader);
                        attributes.Add(attribute);
                        break;
                    case PrerequisiteElementName:
                        PrerequisiteDefinition prerequisite = ReadPrerequisite(reader, baseDirectory);
                        prerequisites.Add(prerequisite);
                        break;
                }
            }
            ProfilingTypeDefinition definition = new ProfilingTypeDefinition(uid, frameworkUid, isHidden, exports, dependencies, localizations, attributes, prerequisites);
            return definition;
        }

19 View Source File : DrawingParser.cs
License : MIT License
Project Creator : ahopper

private static GradientStops ParseGradientStops(XmlReader reader)
        {
            var gradientStops = new GradientStops();

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "GradientStop")
                    {
                        gradientStops.Add(ParseGradientStop(reader));
                    }
                }
            }
            return gradientStops;
        }

19 View Source File : DrawingParser.cs
License : MIT License
Project Creator : ahopper

private static DrawingGroup ParseDrawingGroup(XmlReader reader)
        {

            var drawingGroup = new DrawingGroup();
            
            reader.MoveToElement();
            reader = reader.ReadSubtree();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "GeometryDrawing")
                    {
                        drawingGroup.Children.Add(ParseGeometryDrawing(reader));
                    }
                }
            }
            return drawingGroup;
        }

19 View Source File : XmlFoldingStrategy.cs
License : MIT License
Project Creator : Abdesol

public IEnumerable<NewFolding> CreateNewFoldings(TextDoreplacedent doreplacedent, XmlReader reader, out int firstErrorOffset)
		{
			Stack<XmlFoldStart> stack = new Stack<XmlFoldStart>();
			List<NewFolding> foldMarkers = new List<NewFolding>();
			try {
				while (reader.Read()) {
					switch (reader.NodeType) {
						case XmlNodeType.Element:
							if (!reader.IsEmptyElement) {
								XmlFoldStart newFoldStart = CreateElementFoldStart(doreplacedent, reader);
								stack.Push(newFoldStart);
							}
							break;

						case XmlNodeType.EndElement:
							XmlFoldStart foldStart = stack.Pop();
							CreateElementFold(doreplacedent, foldMarkers, reader, foldStart);
							break;

						case XmlNodeType.Comment:
							CreateCommentFold(doreplacedent, foldMarkers, reader);
							break;
					}
				}
				firstErrorOffset = -1;
			} catch (XmlException ex) {
				// ignore errors at invalid positions (prevent ArgumentOutOfRangeException)
				if (ex.LineNumber >= 1 && ex.LineNumber <= doreplacedent.LineCount)
					firstErrorOffset = doreplacedent.GetOffset(ex.LineNumber, ex.LinePosition);
				else
					firstErrorOffset = 0;
			}
			foldMarkers.Sort((a, b) => a.StartOffset.CompareTo(b.StartOffset));
			return foldMarkers;
		}

19 View Source File : HtmlFromXamlConverter.cs
License : GNU Affero General Public License v3.0
Project Creator : akshinmustafayev

private static bool ReadNextToken(XmlReader xamlReader)
		{
			while (xamlReader.Read())
			{
				Debug.replacedert(xamlReader.ReadState == ReadState.Interactive, "Reader is expected to be in Interactive state (" + xamlReader.ReadState + ")");
				switch (xamlReader.NodeType)
				{
				    case XmlNodeType.Element: 
				    case XmlNodeType.EndElement:
				    case XmlNodeType.None:
				    case XmlNodeType.CDATA:
				    case XmlNodeType.Text:
				    case XmlNodeType.SignificantWhitespace:
					    return true;

				    case XmlNodeType.Whitespace:
					    if (xamlReader.XmlSpace == XmlSpace.Preserve)
					    {
						    return true;
					    }
					    // ignore insignificant whitespace
					    break;

				    case XmlNodeType.EndEnreplacedy:
				    case XmlNodeType.EnreplacedyReference:
                        //  Implement enreplacedy reading
					    //xamlReader.ResolveEnreplacedy();
					    //xamlReader.Read();
					    //ReadChildNodes( parent, parentBaseUri, xamlReader, positionInfo);
                        break; // for now we ignore enreplacedies as insignificant stuff

                    case XmlNodeType.Comment:
                        return true;
                    case XmlNodeType.ProcessingInstruction:
				    case XmlNodeType.DoreplacedentType:
				    case XmlNodeType.XmlDeclaration:
				    default:
					    // Ignorable stuff
					    break;
				}
            }
            return false;
        }

19 View Source File : ReferenceLinks.cs
License : MIT License
Project Creator : actions

void IXmlSerializable.ReadXml(XmlReader reader)
        {
            XmlSerializer keySerializer = new XmlSerializer(typeof(string));
            XmlSerializer valueSerializer = new XmlSerializer(typeof(List<ReferenceLink>));

            bool wasEmpty = reader.IsEmptyElement;
            reader.Read();

            if (wasEmpty)
            {
                return;
            }

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                reader.ReadStartElement("item");

                reader.ReadStartElement("key");
                var key = (string)keySerializer.Deserialize(reader);
                reader.ReadEndElement();

                reader.ReadStartElement("value");
                var value = (List<ReferenceLink>)valueSerializer.Deserialize(reader);
                reader.ReadEndElement();

                if (value.Count == 1)
                {
                    referenceLinks.Add(key, value[0]);
                }
                else if (value.Count > 1)
                {
                    referenceLinks.Add(key, value);
                }

                reader.ReadEndElement();
                reader.MoveToContent();
            }
            reader.ReadEndElement();
        }

19 View Source File : InstanceRef.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void ReadXml(XmlReader reader)
        {
            string v;

            Base = (v = reader[nameof(Base)]) != null ? new Uri(v) : null;
            Popularity = (v = reader[nameof(Popularity)]) != null && float.TryParse(v, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var v_popularity) ? Popularity = v_popularity : 1.0f;

            if (reader.IsEmptyElement)
                return;

            while (reader.Read() &&
                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == GetType().Name))
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == nameof(ProfileRefList))
                {
                    if (reader["Key"] == nameof(Profiles))
                    {
                        Profiles = new ProfileRefList();
                        Profiles.ReadXml(reader);
                    }
                }
            }
        }

19 View Source File : XmlResponseParser.cs
License : Apache License 2.0
Project Creator : aloneguid

public string ParseInitiateMultipartUploadResponse(string xml)
      {
         using(var sr = new StringReader(xml))
         {
            using(var xr = XmlReader.Create(sr))
            {
               string en = null;

               while(xr.Read())
               {
                  if(xr.NodeType == XmlNodeType.Element && xr.Name == "UploadId")
                  {
                     xr.Read();
                     return xr.Value;
                  }
               }
            }
         }

         return null;
      }

19 View Source File : ConnectionData.cs
License : MIT License
Project Creator : actions

internal static ConnectionData FromXml(IServiceProvider serviceProvider, XmlReader reader)
        {
            ConnectionData obj = new ConnectionData();
            Debug.replacedert(reader.NodeType == XmlNodeType.Element, "Expected a node.");

            Boolean empty = reader.IsEmptyElement;

            // Process the xml attributes
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    switch (reader.Name)
                    {
                        case "CatalogResourceId":
                            obj.m_catalogResourceId = XmlConvert.ToGuid(reader.Value);
                            break;
                        case "InstanceId":
                            obj.InstanceId = XmlConvert.ToGuid(reader.Value);
                            break;
                        case "ServerCapabilities":
                            obj.m_serverCapabilities = XmlConvert.ToInt32(reader.Value);
                            break;
                        case "WebApplicationRelativeDirectory":
                            obj.WebApplicationRelativeDirectory = reader.Value;
                            break;
                        default:
                            // Allow attributes such as xsi:type to fall through
                            break;
                    }
                }
            }

            // Process the fields in Xml elements
            reader.Read();
            if (!empty)
            {
                while (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "AuthenticatedUser":
                            obj.AuthenticatedUser = IC.Idenreplacedy.FromXml(serviceProvider, reader);
                            break;
                        case "AuthorizedUser":
                            obj.AuthorizedUser = IC.Idenreplacedy.FromXml(serviceProvider, reader);
                            break;
                        case "LocationServiceData":
                            obj.LocationServiceData = LocationServiceData.FromXml(serviceProvider, reader);
                            break;
                        default:
                            // Make sure that we ignore XML node trees we do not understand
                            reader.ReadOuterXml();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            return obj;
        }

19 View Source File : UriList.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
                return;

            while (reader.Read() &&
                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == GetType().Name))
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "Uri")
                    Add(new Uri(reader["AbsoluteUri"]));
            }
        }

19 View Source File : ConnectionData.cs
License : MIT License
Project Creator : actions

internal static LocationServiceData FromXml(IServiceProvider serviceProvider, XmlReader reader)
        {
            LocationServiceData obj = new LocationServiceData();
            Debug.replacedert(reader.NodeType == XmlNodeType.Element, "Expected a node.");

            Boolean empty = reader.IsEmptyElement;

            // Process the xml attributes
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    switch (reader.Name)
                    {
                        case "AccessPointsDoNotIncludeWebAppRelativeDirectory":
                            obj.m_accessPointsDoNotIncludeWebAppRelativeDirectory = XmlConvert.ToBoolean(reader.Value);
                            break;
                        case "ClientCacheFresh":
                            obj.ClientCacheFresh = XmlConvert.ToBoolean(reader.Value);
                            break;
                        case "DefaultAccessMappingMoniker":
                            obj.DefaultAccessMappingMoniker = reader.Value;
                            break;
                        case "LastChangeId":
                            obj.LastChangeId = XmlConvert.ToInt32(reader.Value);
                            break;
                        case "ClientCacheTimeToLive":
                            obj.ClientCacheTimeToLive = XmlConvert.ToInt32(reader.Value);
                            break;
                        default:
                            // Allow attributes such as xsi:type to fall through
                            break;
                    }                    
                }
            }

            // Process the fields in Xml elements
            reader.Read();
            if (!empty)
            {
                while (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "AccessMappings":
                            obj.AccessMappings = XmlUtility.ArrayOfObjectFromXml<AccessMapping>(serviceProvider, reader, "AccessMapping", false, AccessMapping.FromXml);
                            break;
                        case "ServiceDefinitions":
                            obj.ServiceDefinitions = XmlUtility.ArrayOfObjectFromXml<ServiceDefinition>(serviceProvider, reader, "ServiceDefinition", false, ServiceDefinition.FromXml);
                            break;
                        default:
                            // Make sure that we ignore XML node trees we do not understand
                            reader.ReadOuterXml();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            return obj;
        }

19 View Source File : AccessTokenDictionary.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
                return;

            while (reader.Read() &&
                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == GetType().Name))
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "AccessToken")
                {
                    var key = reader["Key"];
                    if (key == null)
                        throw new FormatException();

                    // Carefully decode access token as it might be damaged or encrypted using another session key.
                    try { this[key] = AccessToken.FromBase64String(reader["Value"]); }
                    catch { }
                }
            }
        }

19 View Source File : TokenDecrypt.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public static string Decrypt(string xml)
        {
            var sr = new StringReader(xml) ;
            var xr = XmlReader.Create(sr) ;
            xr.ReadToDescendant("trust:RequestSecurityTokenResponse") ;
            xr.ReadToFollowing("trust:RequestedSecurityToken") ;
            xr.ReadToDescendant("xenc:EncryptedData") ;
            xr.ReadToDescendant("KeyInfo") ;
            xr.ReadToDescendant("e:EncryptedKey") ;
            xr.ReadToDescendant("KeyInfo") ;
            xr.ReadToDescendant("o:SecurityTokenReference") ;
            xr.ReadToDescendant("X509Data") ;
            xr.ReadToDescendant("X509IssuerSerial") ;
            xr.ReadToDescendant("X509IssuerName") ;
            xr.Read() ;
            var cername = xr.ReadContentreplacedtring().Trim() ;
            xr.ReadToNextSibling("X509SerialNumber") ;
            xr.Read() ;
            var cersn = xr.ReadContentreplacedtring().Trim() ;
            xr.Close() ;
            var doc = new XmlDoreplacedent() ;
            doc.InnerXml = xml ;
            var xm = new XmlNamespaceManager(doc.NameTable) ;
            xm.AddNamespace("trust" , "http://docs.oasis-open.org/ws-sx/ws-trust/200512") ;
            xm.AddNamespace("wsu" , "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd") ;
            xm.AddNamespace("xenc" , "http://www.w3.org/2001/04/xmlenc#") ;
            xm.AddNamespace("e" , "http://www.w3.org/2001/04/xmlenc#") ;
            xm.AddNamespace("e" , "http://www.w3.org/2001/04/xmlenc#") ;
            xm.AddNamespace("" , "http://www.w3.org/2000/09/xmldsig#") ;
            var old = doc.SelectSingleNode("//trust:RequestSecurityTokenResponse" , xm) ;
            if(old == null)
            {
                return null ;
            }
            old = old.SelectSingleNode("//trust:RequestedSecurityToken" , xm) ;
            if(old == null)
            {
                return null ;
            }
            old = old.SelectSingleNode("//xenc:EncryptedData" , xm) ;
            if(old != null)
            {
                foreach(XmlNode n in old.ChildNodes)
                {
                    if(n.LocalName != "KeyInfo")
                    {
                        continue ;
                    }
                    old = n ;
                    break ;
                }
            }
            if(old == null)
            {
                return null ;
            }
            old = old.SelectSingleNode("//e:EncryptedKey" , xm) ;
            if(old == null)
            {
                return null ;
            }
            foreach(XmlNode n in old.ChildNodes)
            {
                if(n.LocalName != "KeyInfo")
                {
                    continue ;
                }
                old = n ;
                break ;
            }
            old.InnerXml = "<KeyName>rsaKey</KeyName>" ;
            DecryptDoreplacedent(doc , cername , cersn , "rsaKey") ;
            return doc.InnerXml ;
        }

19 View Source File : InstanceSourceSettings.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public virtual void ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
                return;

            while (reader.Read() &&
                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == GetType().Name))
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader["Key"] == nameof(InstanceSource))
                    {
                        switch (reader.Name)
                        {
                            case nameof(InstanceSourceSettingsBase): InstanceSource = new InstanceSourceSettingsBase(); break;
                            case nameof(LocalInstanceSourceSettings): InstanceSource = new LocalInstanceSourceSettings(); break;
                        }

                        if (InstanceSource != null)
                        {
                            // Read element.
                            InstanceSource.ReadXml(reader);
                        }
                        else
                        {
                            // Skip unknown element.
                            var name = reader.Name;
                            while (reader.Read() &&
                                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == name)) ;
                        }
                    }
                }
            }
        }

19 View Source File : V2Loader.cs
License : MIT License
Project Creator : Abdesol

static XshdSpan ParseSpan(XmlReader reader)
		{
			XshdSpan span = new XshdSpan();
			SetPosition(span, reader);
			span.BeginRegex = reader.GetAttribute("begin");
			span.EndRegex = reader.GetAttribute("end");
			span.Multiline = reader.GetBoolAttribute("multiline") ?? false;
			span.SpanColorReference = ParseColorReference(reader);
			span.RuleSetReference = ParseRuleSetReference(reader);
			if (!reader.IsEmptyElement) {
				reader.Read();
				while (reader.NodeType != XmlNodeType.EndElement) {
					Debug.replacedert(reader.NodeType == XmlNodeType.Element);
					switch (reader.Name) {
						case "Begin":
							if (span.BeginRegex != null)
								throw Error(reader, "Duplicate Begin regex");
							span.BeginColorReference = ParseColorReference(reader);
							span.BeginRegex = reader.ReadElementString();
							span.BeginRegexType = XshdRegexType.IgnorePatternWhitespace;
							break;
						case "End":
							if (span.EndRegex != null)
								throw Error(reader, "Duplicate End regex");
							span.EndColorReference = ParseColorReference(reader);
							span.EndRegex = reader.ReadElementString();
							span.EndRegexType = XshdRegexType.IgnorePatternWhitespace;
							break;
						case "RuleSet":
							if (span.RuleSetReference.ReferencedElement != null)
								throw Error(reader, "Cannot specify both inline RuleSet and RuleSet reference");
							span.RuleSetReference = new XshdReference<XshdRuleSet>(ParseRuleSet(reader));
							reader.Read();
							break;
						default:
							throw new NotSupportedException("Unknown element " + reader.Name);
					}
				}
			}
			return span;
		}

19 View Source File : ProfileRefList.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
                return;

            while (reader.Read() &&
                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == GetType().Name))
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == nameof(ProfileRef))
                {
                    var el = new ProfileRef();
                    el.ReadXml(reader);
                    Add(el);
                }
            }
        }

19 View Source File : DrawingParser.cs
License : MIT License
Project Creator : ahopper

public static Drawing? Parse(string src)
        {
            Drawing? drawing = null;
            using (XmlReader reader = XmlReader.Create(new StringReader(src)))
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        var tag = reader.Name;
                        switch (tag)
                        {
                            case "GeometryDrawing": drawing = ParseGeometryDrawing(reader); break;
                            case "DrawingGroup": drawing = ParseDrawingGroup(reader); break;
                        }
                    }
                }
            }
            return drawing;
        }

19 View Source File : OrganizationListTests.cs
License : GNU General Public License v3.0
Project Creator : Amebis

[TestMethod()]
        public void OrganizationsNetworkTest()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;

            var xmlReader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(@"<ResourceRef Uri=""https://disco.eduvpn.org/v2/organization_list.json"">
						<MinisignPublicKeyDictionary Key=""PublicKeys"">
							<PublicKey>RWRtBSX1alxyGX+Xn3LuZnWUT0w//B6EmTJvgaAxBMYzlQeI+jdrO6KF</PublicKey>
							<PublicKey>RWQKqtqvd0R7rUDp0rWzbtYPA3towPWcLDCl7eY9pBMMI/ohCmrS0WiM</PublicKey>
						</MinisignPublicKeyDictionary>
					</ResourceRef>")));
            while (xmlReader.ReadState == ReadState.Initial)
                xmlReader.Read();
            var source = new ResourceRef();
            source.ReadXml(xmlReader);

            // Load list of organizations.
            var organizationListJson = Xml.Response.Get(source);
            var dict = new OrganizationDictionary();
            dict.LoadJSON(organizationListJson.Value);

            // Re-load list of organizations.
            Xml.Response.Get(
                res: source,
                previous: organizationListJson);
        }

19 View Source File : ServiceDefinition.cs
License : MIT License
Project Creator : actions

internal static ServiceDefinition FromXml(IServiceProvider serviceProvider, XmlReader reader)
        {
            ServiceDefinition obj = new ServiceDefinition();
            Debug.replacedert(reader.NodeType == XmlNodeType.Element, "Expected a node.");

            Boolean empty = reader.IsEmptyElement;

            // Process the xml attributes
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    switch (reader.Name)
                    {
                        case "description":
                            obj.Description = reader.Value;
                            break;
                        case "displayName":
                            obj.DisplayName = reader.Value;
                            break;
                        case "identifier":
                            obj.Identifier = XmlConvert.ToGuid(reader.Value);
                            break;
                        case "isSingleton":
                            obj.m_isSingleton = XmlConvert.ToBoolean(reader.Value);
                            break;
                        case "relativePath":
                            obj.RelativePath = reader.Value;
                            break;
                        case "relativeToSetting":
                            obj.RelativeToSetting = (RelativeToSetting)XmlConvert.ToInt32(reader.Value);
                            break;
                        case "serviceType":
                            obj.ServiceType = reader.Value;
                            break;
                        case "toolId":
                            obj.ToolId = reader.Value;
                            break;
                        case "resourceVersion":
                            obj.ResourceVersion = XmlConvert.ToInt32(reader.Value);
                            break;
                        case "minVersion":
                            obj.MinVersionString = reader.Value;
                            break;
                        case "maxVersion":
                            obj.MaxVersionString = reader.Value;
                            break;
                        case "releasedVersion":
                            obj.ReleasedVersionString = reader.Value;
                            break;
                        default:
                            // Allow attributes such as xsi:type to fall through
                            break;
                    }
                }
            }

            // Process the fields in Xml elements
            reader.Read();
            if (!empty)
            {
                while (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "LocationMappings":
                            obj.LocationMappings = new List<LocationMapping>(XmlUtility.ArrayOfObjectFromXml<LocationMapping>(serviceProvider, reader, "LocationMapping", false, LocationMapping.FromXml));
                            break;
                        case "Properties":
                            // Ignore properties
                            reader.ReadOuterXml();
                            break;
                        default:
                            // Make sure that we ignore XML node trees we do not understand
                            reader.ReadOuterXml();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            return obj;
        }

19 View Source File : Functions.cs
License : Apache License 2.0
Project Creator : AmpScm

public static StringCollection GetXMLTextLines(XmlReader Reader, WhitespaceHandling eWS)
        {
            StringCollection Coll = new StringCollection();
            StringBuilder B = new StringBuilder();
            bool bTrimWSInSplit = eWS != WhitespaceHandling.All;

            //Read each node in the tree.
            string strIndent = "";
            int iCurrentDepth = 0;
            while (Reader.Read())
            {
                int iDepth = Reader.Depth;
                if (iDepth != iCurrentDepth)
                {
                    strIndent = GetIndentString(iDepth);
                    iCurrentDepth = iDepth;
                }

                switch (Reader.NodeType)
                {
                    case XmlNodeType.Attribute: //This should never be returned by XmlReader
                        Coll.Add(String.Format("{2}{0}={3}{1}{3}", Reader.Name, Reader.Value, strIndent, Reader.QuoteChar));
                        break;

                    case XmlNodeType.Comment:
                        SplitAndAddXMLLines(Coll, String.Format("<!-- {0} -->", Reader.Value), strIndent, bTrimWSInSplit);
                        break;

                    case XmlNodeType.Element:
                        B.Length = 0;
                        B.AppendFormat("{1}<{0}", Reader.Name, strIndent);
                        //We have to check for this before we move to the attributes.
                        bool bIsEmptyElement = Reader.IsEmptyElement;
                        while (Reader.MoveToNextAttribute())
                        {
                            B.AppendFormat(" {0}={2}{1}{2}", Reader.Name, Reader.Value, Reader.QuoteChar);
                        }
                        if (bIsEmptyElement)
                            B.Append("/>");
                        else
                            B.Append(">");
                        Coll.Add(B.ToString());
                        break;

                    case XmlNodeType.EndElement:
                        Coll.Add(String.Format("{1}</{0}>", Reader.Name, strIndent));
                        break;

                    case XmlNodeType.ProcessingInstruction:
                    case XmlNodeType.XmlDeclaration:
                        Coll.Add(String.Format("{2}<?{0} {1}?>", Reader.Name, Reader.Value, strIndent));
                        break;

                    case XmlNodeType.SignificantWhitespace:
                        if (eWS != WhitespaceHandling.None)
                        {
                            Coll.Add(String.Format("{1}{0}", Reader.Value, strIndent));
                        }
                        break;

                    case XmlNodeType.Whitespace:
                        if (eWS == WhitespaceHandling.All)
                        {
                            Coll.Add(String.Format("{1}{0}", Reader.Value, strIndent));
                        }
                        break;

                    case XmlNodeType.CDATA:
                        Coll.Add(String.Format("{1}<![CDATA[{0}]]>", Reader.Value, strIndent));
                        break;

                    case XmlNodeType.Doreplacedent:
                    case XmlNodeType.DoreplacedentFragment:
                        Coll.Add(String.Format("{1}{0}", Reader.Value, strIndent));
                        break;

                    case XmlNodeType.DoreplacedentType:
                        Coll.Add(String.Format("{1}<!DOCTYPE {0} [", Reader.Name, strIndent));
                        SplitAndAddXMLLines(Coll, Reader.Value, GetIndentString(iDepth + 1), bTrimWSInSplit);
                        Coll.Add(String.Format("{0}]>", strIndent));
                        break;

                    case XmlNodeType.Enreplacedy:
                        Coll.Add(String.Format("{2}<!ENreplacedY {0} [{1}]", Reader.Name, Reader.Value, strIndent));
                        SplitAndAddXMLLines(Coll, Reader.Value, GetIndentString(iDepth + 1), bTrimWSInSplit);
                        Coll.Add(String.Format("{0}]>", strIndent));
                        break;

                    case XmlNodeType.EnreplacedyReference:
                        Coll.Add(String.Format("{1}&{0}", Reader.Value, strIndent));
                        break;

                    case XmlNodeType.Notation:
                        Coll.Add(String.Format("{2}<!NOTATION {0} [{1}]>", Reader.Name, Reader.Value, strIndent));
                        break;

                    case XmlNodeType.EndEnreplacedy:
                    case XmlNodeType.None:
                    case XmlNodeType.Text:
                        SplitAndAddXMLLines(Coll, Reader.Value, strIndent, bTrimWSInSplit);
                        break;
                }
            }

            return Coll;
        }

19 View Source File : DrawingParser.cs
License : MIT License
Project Creator : ahopper

private static Geometry? ParseGeometry(XmlReader reader)
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "EllipseGeometry": return ParseEllipseGeometry(reader);
                        case "RectangleGeometry": return ParseRectangleGeometry(reader);
                    }
                }
            }
            return null;
        }

19 View Source File : XmlLayoutReader.cs
License : GNU General Public License v3.0
Project Creator : AndreiFedarets

private MenuItem ReadMenuItem(XmlReader reader, IContainer container)
        {
            //Move to <MenuItem> element
            MoveToElement(reader, MenuItemElementName);

            string id = string.Empty;
            Type controlHandlerType = typeof(MenuControlHandlerDefault);

            //Read <MenuItem> attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                    case IdAttributeName:
                        id = reader.ReadContentreplacedtring();
                        break;
                    case TypeAttributeName:
                        string type = reader.ReadContentreplacedtring();
                        controlHandlerType = Type.GetType(type);
                        break;
                }
            }

            MenuItem control = new MenuItem(id);
            IMenuControlHandler controlHandler = new MenuControlHandlerLazy(controlHandlerType, container);
            control.AttachHandler(controlHandler);

            //Read <MenuItem> element content
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement && string.Equals(MenuItemElementName, reader.Name))
                {
                    break;
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (reader.Name)
                {
                    case MenuItemElementName:
                        MenuItem menuItem = ReadMenuItem(reader, container);
                        control.Add(menuItem);
                        break;
                }
            }   

            return control;
        }

19 View Source File : V2Loader.cs
License : MIT License
Project Creator : Abdesol

static void ParseElements(ICollection<XshdElement> c, XmlReader reader)
		{
			if (reader.IsEmptyElement)
				return;
			while (reader.Read() && reader.NodeType != XmlNodeType.EndElement) {
				Debug.replacedert(reader.NodeType == XmlNodeType.Element);
				if (reader.NamespaceURI != Namespace) {
					if (!reader.IsEmptyElement)
						reader.Skip();
					continue;
				}
				switch (reader.Name) {
					case "RuleSet":
						c.Add(ParseRuleSet(reader));
						break;
					case "Property":
						c.Add(ParseProperty(reader));
						break;
					case "Color":
						c.Add(ParseNamedColor(reader));
						break;
					case "Keywords":
						c.Add(ParseKeywords(reader));
						break;
					case "Span":
						c.Add(ParseSpan(reader));
						break;
					case "Import":
						c.Add(ParseImport(reader));
						break;
					case "Rule":
						c.Add(ParseRule(reader));
						break;
					default:
						throw new NotSupportedException("Unknown element " + reader.Name);
				}
			}
		}

19 View Source File : XmlExtensionReader.cs
License : GNU General Public License v3.0
Project Creator : AndreiFedarets

private AttachmentDefinition ReadAttachment(XmlReader reader, string baseDirectory)
        {
            //Move to <ProfilingType> element
            MoveToElement(reader, AttachmentElementName);
            Guid targetUid = Guid.Empty;
            List<ExportDefinition> exports = new List<ExportDefinition>();
            List<DependencyDefinition> dependencies = new List<DependencyDefinition>();
            List<AttributeDefinition> attributes = new List<AttributeDefinition>();

            //Read Attachment attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                    case AttachmentTargetUidAttributeName:
                        targetUid = reader.ReadContentAsGuid();
                        break;
                }
            }

            //Move back to <Attachment> element
            reader.MoveToElement();

            //Read <Attachment> element content
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement &&
                    string.Equals(AttachmentElementName, reader.Name))
                {
                    break;
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (reader.Name)
                {
                    case ExportElementName:
                        ExportDefinition export = ReadExport(reader, baseDirectory);
                        exports.Add(export);
                        break;
                    case DependencyElementName:
                        DependencyDefinition dependency = ReadDependency(reader);
                        dependencies.Add(dependency);
                        break;
                    case AttributeElementName:
                        AttributeDefinition attribute = ReadAttribute(reader);
                        attributes.Add(attribute);
                        break;
                }
            }
            AttachmentDefinition definition = new AttachmentDefinition(targetUid, exports, dependencies, attributes);
            return definition;
        }

19 View Source File : DrawingParser.cs
License : MIT License
Project Creator : ahopper

private static LinearGradientBrush ParseLinearGradientBrush(XmlReader reader)
        {
            LinearGradientBrush brush = new LinearGradientBrush();
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                    case "StartPoint": brush.StartPoint = RelativePoint.Parse(reader.Value); break;
                    case "EndPoint": brush.EndPoint = RelativePoint.Parse(reader.Value); break;
                }
            }
            reader.MoveToElement();
            reader = reader.ReadSubtree();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "LinearGradientBrush.GradientStops": brush.GradientStops = ParseGradientStops(reader.ReadSubtree()); break;
                    }
                }
            }
            return brush;
        }

19 View Source File : IdentityDescriptor.cs
License : MIT License
Project Creator : actions

internal static IdenreplacedyDescriptor FromXml(IServiceProvider serviceProvider, XmlReader reader)
        {
            string identifier = string.Empty;
            string idenreplacedyType = string.Empty;

            Debug.replacedert(reader.NodeType == XmlNodeType.Element, "Expected a node.");

            bool empty = reader.IsEmptyElement;

            // Process the xml attributes
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    switch (reader.Name)
                    {
                        case "identifier":
                            identifier = reader.Value;
                            break;
                        case "idenreplacedyType":
                            idenreplacedyType = reader.Value;
                            break;
                        default:
                            // Allow attributes such as xsi:type to fall through
                            break;
                    }
                }
            }

            IdenreplacedyDescriptor obj = new IdenreplacedyDescriptor(idenreplacedyType, identifier);

            // Process the fields in Xml elements
            reader.Read();
            if (!empty)
            {
                while (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        default:
                            // Make sure that we ignore XML node trees we do not understand
                            reader.ReadOuterXml();
                            break;
                    }
                }
                reader.ReadEndElement();
            }

            return obj;
        }

19 View Source File : HotKeys.cs
License : MIT License
Project Creator : 3RD-Dimension

public static void LoadHotKeys()
        {           
            hotkeyCode.Clear();
            hotkeyDescription.Clear();

            if (!File.Exists(HotKeyFile))
            {
               MainWindow.Logger.Error("Hotkey file not found, going to create default");
                CheckCreateFile.CreateDefaultXML();               
            }
 
            XmlReader r = XmlReader.Create(HotKeyFile);   // "hotkeys.xml");

            while (r.Read())
            {
                if (!r.IsStartElement())
                    continue;

                switch (r.Name)
                {
                    case "Hotkeys":
                        // Get Hotkey Version Number, used for modifying or updating to newer hotkey files (ie if new features are added)
                        if (r["HotkeyFileVer"].Length > 0)
                        {                           
                            CurrentHotKeyFileVersion = Convert.ToInt32(r["HotkeyFileVer"]); // Current Hotkey File Version
                        }
                        break;
                    case "bind":
                        if ((r["keyfunction"].Length > 0) && (r["keycode"] != null))
                        {
                            if (!hotkeyCode.ContainsKey(r["keyfunction"]))
                                hotkeyCode.Add(r["keyfunction"], r["keycode"]);
                            hotkeyDescription.Add(r["keyfunction"], r["key_description"]);
                        }
                        break;
                }              
            }
            r.Close();

            // Check if CurrentFileVersion and NewFileVersion is different and if so, Update the file then reload by running ths process again.
            MainWindow.Logger.Info("Hotkey file found, checking if needing update/modification");
            if (CurrentHotKeyFileVersion < CheckCreateFile.HotKeyFileVer) // If CurrentHotKeyFileVersion does not equal HotKeyFileVer then update is required
            {
                 CheckCreateFile.CheckAndUpdateXMLFile(CurrentHotKeyFileVersion);
             }           
        }

19 View Source File : V2Loader.cs
License : MIT License
Project Creator : Abdesol

static XshdKeywords ParseKeywords(XmlReader reader)
		{
			XshdKeywords keywords = new XshdKeywords();
			SetPosition(keywords, reader);
			keywords.ColorReference = ParseColorReference(reader);
			reader.Read();
			while (reader.NodeType != XmlNodeType.EndElement) {
				Debug.replacedert(reader.NodeType == XmlNodeType.Element);
				keywords.Words.Add(reader.ReadElementString());
			}
			return keywords;
		}

19 View Source File : V2Loader.cs
License : MIT License
Project Creator : Abdesol

static XshdRule ParseRule(XmlReader reader)
		{
			XshdRule rule = new XshdRule();
			SetPosition(rule, reader);
			rule.ColorReference = ParseColorReference(reader);
			if (!reader.IsEmptyElement) {
				reader.Read();
				if (reader.NodeType == XmlNodeType.Text) {
					rule.Regex = reader.ReadContentreplacedtring();
					rule.RegexType = XshdRegexType.IgnorePatternWhitespace;
				}
			}
			return rule;
		}

19 View Source File : Identity.cs
License : MIT License
Project Creator : actions

internal static Idenreplacedy FromXml(IServiceProvider serviceProvider, XmlReader reader)
        {
            Idenreplacedy obj = new Idenreplacedy();
            Debug.replacedert(reader.NodeType == XmlNodeType.Element, "Expected a node.");

            bool empty = reader.IsEmptyElement;

            // Process the xml attributes
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    switch (reader.Name)
                    {
                        case "DisplayName":
                            obj.ProviderDisplayName = reader.Value;
                            break;
                        case "IsActive":
                            obj.IsActive = XmlConvert.ToBoolean(reader.Value);
                            break;
                        case "IsContainer":
                            obj.IsContainer = XmlConvert.ToBoolean(reader.Value);
                            break;
                        case "TeamFoundationId":
                            obj.Id = XmlConvert.ToGuid(reader.Value);
                            break;
                        case "UniqueName":
                            // We don't have this property on VSIdenreplacedy
                            //obj.UniqueName = reader.Value;
                            break;
                        case "UniqueUserId":
                            obj.UniqueUserId = XmlConvert.ToInt32(reader.Value);
                            break;
                        default:
                            // Allow attributes such as xsi:type to fall through
                            break;
                    }
                }
            }

            // Process the fields in Xml elements
            reader.Read();
            if (!empty)
            {
                while (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "Attributes":
                            KeyValueOfStringString[] attributes = XmlUtility.ArrayOfObjectFromXml<KeyValueOfStringString>(serviceProvider, reader, "KeyValueOfStringString", false, KeyValueOfStringString.FromXml);
                            if (attributes != null && obj.Properties != null)
                            {
                                foreach (KeyValueOfStringString attribute in attributes)
                                {
                                    obj.Properties[attribute.Key] = attribute.Value;
                                }
                            }
                            break;
                        case "Descriptor":
                            obj.Descriptor = IdenreplacedyDescriptor.FromXml(serviceProvider, reader);
                            break;
                        case "LocalProperties":
                            // Since we're only using the SOAP serializer for bootstrap, we won't support properties
                            //obj.m_localPropertiesSet = Helper.ArrayOfPropertyValueFromXml(serviceProvider, reader, false);
                            reader.ReadOuterXml();
                            break;
                        case "MemberOf":
                            obj.MemberOf = XmlUtility.ArrayOfObjectFromXml<IdenreplacedyDescriptor>(serviceProvider, reader, "IdenreplacedyDescriptor", false, IdenreplacedyDescriptor.FromXml);
                            break;
                        case "Members":
                            obj.Members = XmlUtility.ArrayOfObjectFromXml<IdenreplacedyDescriptor>(serviceProvider, reader, "IdenreplacedyDescriptor", false, IdenreplacedyDescriptor.FromXml);
                            break;
                        case "Properties":
                            // Since we're only using the SOAP serializer for bootstrap, we won't support properties
                            //obj.m_propertiesSet = Helper.ArrayOfPropertyValueFromXml(serviceProvider, reader, false);
                            reader.ReadOuterXml();
                            break;
                        default:
                            // Make sure that we ignore XML node trees we do not understand
                            reader.ReadOuterXml();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            return obj;
        }

19 View Source File : Dictionary.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
                return;

            while (reader.Read() &&
                !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == GetType().Name))
            {
                var element = new T();
                if (reader.NodeType == XmlNodeType.Element && reader.LocalName == element.GetType().Name)
                {
                    var key = reader["Key"];
                    if (key == null)
                        throw new FormatException();

                    element.ReadXml(reader);
                    Add(key, element);
                }
            }
        }

See More Examples