public XmlElementContext([NotNull] SerializationContext original, [CanBeNull] XDeclaration declaration,
                                 [CanBeNull] XNamespace xNamespace, [NotNull] string rootName)
            : base(original)
        {
            XDocument doc = null;
            XElement ele = null;

            switch (original.SerializerMode)
            {
                case SerializerMode.Deserialize:
                    doc = XDocument.Load(TextReader, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
                    break;
                case SerializerMode.Serialize:
                    if (declaration != null)
                    {
                        doc = new XDocument(declaration, new XElement(xNamespace + rootName));
                        _currentElement = doc;
                    }
                    else
                    {
                        ele = new XElement(rootName);
                        _currentElement = ele;
                    }
                    break;
                default:
                    throw new ArgumentOutOfRangeException("mode");
            }

            XElement = ele ?? doc.Root;
        }
示例#2
0
        private void CreateElement(string tagName, object[] args)
        {
            var element = new XElement(tagName);
            _current.Add(element);

            foreach (var arg in args)
            {
                var content = string.Empty;
                Action<dynamic> action = null;
                if (arg is string)
                {
                    content = (string) arg;
                }
                else if (arg is Action<dynamic>)
                {
                    action = (Action<dynamic>) arg;
                }

                if (!String.IsNullOrEmpty(content))
                {
                    element.Add(content);
                }

                if (action != null)
                {
                    _current = element;
                    action(this);
                    _current = element.Parent;
                }
            }
        }
        private static void TraverseWithXDocument(XContainer document, string path)
        {
            bool inDirectories = true;
            string[] folderDirectories = Directory.GetDirectories(path);

            if (0 == folderDirectories.Length)
            {
                folderDirectories = Directory.GetFiles(path);
                inDirectories = false;
            }

            for (int i = 0; i < folderDirectories.Length; i++)
            {
                if (inDirectories)
                {
                    XAttribute attribute = new XAttribute("path", folderDirectories[i]);
                    XElement innerNode = new XElement("dir", attribute);
                    TraverseWithXDocument(innerNode, folderDirectories[i]);
                    document.Add(innerNode);
                }
                else
                {
                    XAttribute attribute = new XAttribute("fileName", Path.GetFileName(folderDirectories[i]));
                    XElement innerNode = new XElement("file", attribute);
                    document.Add(innerNode);
                }
            }
        }
示例#4
0
        //todo: this can become private when we remove the template rule
        public static ImmutableList<RuleParameterValues> ParseParameters(XContainer xml)
        {
            var builder = ImmutableList.CreateBuilder<RuleParameterValues>();
            foreach (var rule in xml.Descendants("Rule").Where(e => e.Elements("Parameters").Any()))
            {
                var analyzerId = rule.Elements("Key").Single().Value;

                var parameterValues = rule
                    .Elements("Parameters").Single()
                    .Elements("Parameter")
                    .Select(e => new RuleParameterValue
                    {
                        ParameterKey = e.Elements("Key").Single().Value,
                        ParameterValue = e.Elements("Value").Single().Value
                    });

                var pvs = new RuleParameterValues
                {
                    RuleId = analyzerId
                };
                pvs.ParameterValues.AddRange(parameterValues);

                builder.Add(pvs);
            }

            return builder.ToImmutable();
        }
示例#5
0
        public void UpdateGeocodes(XContainer result, Org org)
        {
            if (result == null) throw new ArgumentNullException("result");

            var element = result.Element("geometry");

            if (element == null) return;

            var locationElement = element.Element("location");

            if (locationElement == null) return;

            var lat = locationElement.Element("lat");
            if (lat != null)
            {
                org.Lat = lat.Value.ToNullableDouble();
                org.Modified = DateTime.Now;
            }

            var lng = locationElement.Element("lng");
            if (lng != null)
            {
                org.Lon = lng.Value.ToNullableDouble();
                org.Modified = DateTime.Now;
            }
        }
示例#6
0
 /// <summary>
 /// Constructs a new BuildLayoutLoader, loading an XML document listing the supported builds.
 /// </summary>
 /// <param name="buildInfo">The XML document listing the supported builds.</param>
 /// <param name="layoutDirPath">The path to the directory where build layout files are stored. Must end with a slash.</param>
 public BuildInfoLoader(XDocument buildInfo, string layoutDirPath)
 {
     _builds = buildInfo.Element("builds");
     if (_builds == null)
         throw new ArgumentException("Invalid build info document");
     _basePath = layoutDirPath;
 }
 private static dynamic GetSubmission(XContainer doc)
 {
     return (from element in doc.Descendants(Namespaces.XForms + "submission")
             let resource = element.Attribute("resource")
             where resource != null
             select new {Element = element, TargetUri = resource.Value}).FirstOrDefault();
 }
示例#8
0
        public static bool TryParse(XContainer xml, out GoodreadsBook result)
        {
            result = null;

            var bookNode = (xml is XElement && (xml as XElement).Name == "best_book") ? xml as XElement : xml.Descendants("best_book").FirstOrDefault();
            var idNode = (bookNode.Element("id")?.FirstNode as XText)?.Value;
            var titleNode = bookNode.Element("title");
            var authorNode = bookNode.Element("author");

            var title = titleNode?.Value;
            if (string.IsNullOrEmpty(title))
            {
                return false;
            }

            int id;
            if (idNode == null || !int.TryParse(idNode, out id))
            {
                id = int.MinValue;
            }

            GoodreadsAuthor author;
            if (authorNode == null || !GoodreadsAuthor.TryParse(authorNode, out author))
            {
                result = new GoodreadsBook(id, title);
            }
            else
            {
                result = new GoodreadsBook(id, title, author);
            }

            return true;
        }
        internal static List<string> GetGuids(XContainer owningElement, string propertyName)
        {
            var propElement = owningElement.Element(propertyName);

            return (propElement == null) ? new List<string>() : (from osEl in propElement.Elements(SharedConstants.Objsur)
                                                                 select osEl.Attribute(SharedConstants.GuidStr).Value.ToLowerInvariant()).ToList();
        }
示例#10
0
		private static IntacctServiceResponse ParseErrorsIntoResponse(XContainer errorMessage)
		{
			var response = IntacctServiceResponse.Failed;
			response.AddErrors(ParseErrors(errorMessage));

			return response;
		}
 private static void OrderByMinY(XContainer root)
 {
     var elements = root.Elements().ToList();
     elements.ForEach(x => x.Remove());
     elements = elements.OrderBy(x => x, new CircleCyComparer()).ToList();
     elements.ForEach(root.Add);
 }
示例#12
0
        public static IEnumerable<UserSettings> DeserializeAll(XContainer container)
        {
            if (container == null)
                throw new ArgumentNullException("xml");

            return from x in container.Descendants("UserSettings") select Deserialize(x);
        }
        private static void SetOrchestraBoxes(List<DataRow> seats, XContainer root)
        {
            var boxes = GetChildById(root, "OrchestraBoxes");

            var left = GetChildById(boxes, "Left").ReorderElements(OrderBy.ChildMinY);

            var leftBoxes = new List<Tuple<string, int>>
            {
                new Tuple<string, int>("A", 42),
                new Tuple<string, int>("B", 43),
                new Tuple<string, int>("C", 44)
            };

            SetStandardBoxes(seats, left, leftBoxes);

            var right = GetChildById(boxes, "Right").ReorderElements(OrderBy.ChildMinY);

            var rightBoxes = new List<Tuple<string, int>>
            {
                new Tuple<string, int>("H", 47),
                new Tuple<string, int>("G", 46),
                new Tuple<string, int>("F", 45)
            };

            SetStandardBoxes(seats, right, rightBoxes);
        }
示例#14
0
        public static IEnumerable<ClientVersion> DeserializeAll(XContainer container)
        {
            if (container == null)
                throw new ArgumentNullException("container");

            return from x in container.Descendants("ClientVersion") select Deserialize(x);
        }
示例#15
0
 public AddRecordsResponse(XContainer xdoc)
     : base(xdoc)
 {
     Records = GetElements("record").Select(x => (YastRecord) x);
     Projects = GetElements("project").Select(x => (YastProject) x);
     Folders = GetElements("folder").Select(x => (YastFolder) x);
 }
        private static void SetTier2Boxes(List<DataRow> seats, XContainer root)
        {
            var boxes = GetChildById(root, "Tier2Boxes");

            var left = GetChildById(boxes, "Left").ReorderElements(OrderBy.ChildMinY);

            var leftBoxes = new List<Tuple<string, int>>
            {
                new Tuple<string, int>("A", 56),
                new Tuple<string, int>("B", 57),
                new Tuple<string, int>("C", 58),
                new Tuple<string, int>("D", 59)
            };

            SetStandardBoxes(seats, left, leftBoxes);

            var right = GetChildById(boxes, "Right").ReorderElements(OrderBy.ChildMinY);

            var rightBoxes = new List<Tuple<string, int>>
            {
                new Tuple<string, int>("H", 63),
                new Tuple<string, int>("G", 62),
                new Tuple<string, int>("F", 61),
                new Tuple<string, int>("E", 60)
            };

            SetStandardBoxes(seats, right, rightBoxes);
        }
示例#17
0
 private static Dictionary<string, string> GetJoins(XContainer ele)
 {
     if (ele == null)
         return new Dictionary<string, string>();
     var ret = ele.Elements().ToDictionary(j => j.Attribute("name").Value, j => j.Value);
     return ret;
 }
示例#18
0
 /// <summary>
 /// Loads a structure layout based upon an XML container's children.
 /// </summary>
 /// <param name="layoutTag">The collection of structure field tags to parse.</param>
 /// <returns>The structure layout that was loaded.</returns>
 public static StructureLayout LoadLayout(XContainer layoutTag)
 {
     StructureLayout layout = new StructureLayout();
     foreach (XElement element in layoutTag.Elements())
         HandleElement(layout, element);
     return layout;
 }
 private static string GetFormContents(XContainer doc)
 {
     var formContents = (from instance in doc.Descendants(Namespaces.XForms + "instance")
                         let contents = instance.Elements().FirstOrDefault()
                         select contents != null ? contents.ToString(SaveOptions.DisableFormatting) : string.Empty).FirstOrDefault();
     return formContents ?? string.Empty;
 }
        private List<ValidationIssue> ParseIssues(XContainer document, string rootName, string listName, string tagName, Severity severity)
        {
            var elements = from e in document.Descendants(_namespace + rootName) select e;
            var issues = new List<ValidationIssue>();

            foreach (var element in elements)
            {
                foreach (var list in element.Descendants(_namespace + listName))
                {
                    foreach (var errorElement in list.Descendants(_namespace + tagName))
                    {
                        var issue = new ValidationIssue { Severity = severity };

                        if (errorElement.Descendants(_namespace + "line").Any())
                            issue.Row = int.Parse(errorElement.Descendants(_namespace + "line").First().Value);
                        if (errorElement.Descendants(_namespace + "col").Any())
                            issue.Column = int.Parse(errorElement.Descendants(_namespace + "col").First().Value);
                        if (errorElement.Descendants(_namespace + "message").Any())
                        {
                            issue.Title = errorElement.Descendants(_namespace + "message").First().Value;
                            issue.MessageId = Encoding.UTF8.GetString(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(issue.Title)));
                        }

                        issues.Add(issue);
                    }
                }
            }

            return issues;
        }
        static void WithConfigurationSettings(XContainer configuration, Action<string, string, XAttribute> roleSettingNameAndValueAttributeCallback)
        {
            foreach (var roleElement in configuration.Elements()
                .SelectMany(e => e.Elements())
                .Where(e => e.Name.LocalName == "Role"))
            {
                var roleNameAttribute = roleElement.Attributes().FirstOrDefault(x => x.Name.LocalName == "name");
                if (roleNameAttribute == null)
                    continue;

                var configSettingsElement = roleElement.Elements().FirstOrDefault(e => e.Name.LocalName == "ConfigurationSettings");
                if (configSettingsElement == null)
                    continue;

                foreach (var settingElement in configSettingsElement.Elements().Where(e => e.Name.LocalName == "Setting"))
                {
                    var nameAttribute = settingElement.Attributes().FirstOrDefault(x => x.Name.LocalName == "name");
                    if (nameAttribute == null)
                        continue;

                    var valueAttribute = settingElement.Attributes().FirstOrDefault(x => x.Name.LocalName == "value");
                    if (valueAttribute == null)
                        continue;

                    roleSettingNameAndValueAttributeCallback(roleNameAttribute.Value, nameAttribute.Value, valueAttribute);
                }
            }
        }
 private void ExtractFeatures(XContainer layer)
 {
     foreach (var feature in layer.Elements())
     {
         _featureInfo.FeatureInfos.Add(ExtractFeatureElements(feature));
     }
 }
示例#23
0
 private static string GetField(XContainer el, string fieldName)
 {
     var fld = el.Element(fieldName);
     return fld != null
         ? fld.Value
         : "<Missing>";
 }
        private void FillProperties(XContainer xml)
        {
            if (xml == null) return;

            var title = xml.Element("title");
            var subTitle = xml.Element("subtitle");
            var location = xml.Element("location");
            var phone = xml.Element("phone");
            var url = xml.Element("url");
            var urlText = xml.Element("urlText");

            if (title != null) Title = string.IsNullOrEmpty(title.Value) ? null : title.Value;
            if (subTitle != null) SubTitle = string.IsNullOrEmpty(subTitle.Value) ? null : subTitle.Value;
            if (location != null) Location = string.IsNullOrEmpty(location.Value) ? null : location.Value;
            if (phone != null) Phone = string.IsNullOrEmpty(phone.Value) ? null : phone.Value;
            if (url != null) Url = string.IsNullOrEmpty(url.Value) ? null : url.Value;
            if (urlText != null) UrlText = string.IsNullOrEmpty(urlText.Value) ? null : urlText.Value;

            var keyValueList = xml.Element("departmentOrDayOfWeekToTimeList");
            if (keyValueList == null) return;
            var items = keyValueList.Descendants("item");
            foreach (var item in items)
            {
                var key = item.Attribute("key");
                if (key == null) continue;
                var value = item.Element("value");
                if (value != null) LocationOrDayOfWeekToTime.Add(key.Value, value.Value ?? string.Empty);
            }
        }
示例#25
0
        private void ParseXml(XContainer doc)
        {
            var checks = from check in doc.Elements("check")
                         where check.Element("url") != null
                         select new Check
                             {
                                 Url = (string)check.Element("url"),
                                 ContentMatches = (from content in check.Elements("content")
                                                   where content.Element("positive") != null
                                                   select new ContentMatch
                                                    {
                                                         Match = (string)content.Element("positive"),
                                                         Required = true
                                                    })
                                                    .Union(from content in check.Elements("content")
                                                              where content.Element("negative") != null
                                                              select new ContentMatch
                                                    {
                                                        Match = (string)content.Element("negative"),
                                                        Required = false
                                                    })
                                                    .ToList()
                             };

            Checks = checks.ToList();
        }
示例#26
0
		/// <summary>
		/// 	Checkses the calls in element.
		/// </summary>
		/// <param name="ie"> The ie. </param>
		/// <param name="tc"> The tc. </param>
		/// <param name="ic"> The ic. </param>
		/// <remarks>
		/// </remarks>
		private void ChecksCallsInElement(XContainer ie, string tc, string ic) {
			foreach (var e in ie.Elements("call").ToArray()) {
				var code = e.Id();
				if (!Context.Generators.ContainsKey(code)) {
					continue;
				}

				var gen = Context.Generators[code];
				if (gen.IsValid) {
					gen.Execute(Context, e);
					UserLog.Trace("generator " + code + " called in " + tc + "/" + ic + " " + e.Describe().File + ":" +
					              e.Describe().Line);
				}
				else {
					var message = "try call not valid generator with code " + code + " in " + tc + "/" + ic;
					AddError(
						ErrorLevel.Warning,
						message,
						"TW2501",
						null, e.Describe().File, e.Describe().Line
						);
					UserLog.Warn(message);
				}
			}
		}
        public ChoiceParameter(XContainer document)
            : base(document)
        {
            ParameterType = BuildParameterType.ChoiceParameterDefinition;

            Options = document.Elements("choice").Select(a => new NameValuePair(a.Value, a.Value)).ToArray();
        }
        private static string GenerateRequest(XContainer dynListXml, Timespan timespan)
        {
            var sb = new StringBuilder();
            sb.Append("wda=" + GenerateTimespanString(timespan)+ " and ");

            using (var enumerator = dynListXml.Elements().GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    bool isLast;
                    do
                    {
                        var current = enumerator.Current;
                        isLast = !enumerator.MoveNext();
                        sb.Append(current.Name + "=" + current.Value);
                        if (!isLast)
                        {
                            sb.Append(" and ");
                        }
                    } while (!isLast);
                }
            }

            return sb.ToString();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OpenCoverParser"/> class.
        /// </summary>
        /// <param name="report">The report file as XContainer.</param>
        internal OpenCoverParser(XContainer report)
        {
            if (report == null)
            {
                throw new ArgumentNullException(nameof(report));
            }

            this.modules = report.Descendants("Module")
                .Where(m => m.Attribute("skippedDueTo") == null)
                .ToArray();
            this.files = report.Descendants("File").ToArray();
            this.trackedMethods = report.Descendants("TrackedMethod")
                .ToDictionary(t => t.Attribute("uid").Value, t => t.Attribute("name").Value);

            var assemblyNames = this.modules
                .Select(m => m.Element("ModuleName").Value)
                .Distinct()
                .OrderBy(a => a)
                .ToArray();

            Parallel.ForEach(assemblyNames, assemblyName => this.AddAssembly(this.ProcessAssembly(assemblyName)));

            this.modules = null;
            this.files = null;
            this.trackedMethods = null;
        }
示例#30
0
        private void InitRssItems(XContainer doc)
        {
            var items = doc.Descendants(@"item");
            foreach (var item in items)
            {
                var title = item.Element("title");
                var date = item.Element("pubDate");
                var link = item.Element("link");

                if (title == null)
                {
                    throw new XmlException("Xml schema has changed: missing '//item/title' node");
                }
                if (date == null)
                {
                    throw new XmlException("Xml schema has changed: missing '//item/pubDate' node");
                }
                if (link == null)
                {
                    throw new XmlException("Xml schema has changed: missing '//item/link' node");
                }

                _rssVm.Items.Add(new RssItemVm(title.Value, ParseTime(date), link.Value));
            }
        }
示例#31
0
 public override DataTemplate SelectTemplate(object item, DependencyObject container)
 {
     YellowstonePathology.UI.Common.OrderDialog openWindow = null;
     foreach (Window window in Application.Current.Windows)
     {
         if (window.GetType().ToString() == "YellowstonePathology.UI.Common.OrderDialog")
         {
             openWindow = window as YellowstonePathology.UI.Common.OrderDialog;
             break;
         }
     }
     if (item != null)
     {
         System.Xml.Linq.XContainer xContainer = item as System.Xml.Linq.XContainer;
         XElement templateNameElement          = xContainer.Element("TemplateName");
         if (templateNameElement != null)
         {
             return(((System.Windows.Controls.Grid)openWindow.Content).FindResource(templateNameElement.Value) as DataTemplate);
         }
         return(((System.Windows.Controls.Grid)openWindow.Content).FindResource("StandardCheckBoxTemplate") as DataTemplate);
     }
     return(((YellowstonePathology.UI.Common.OrderDialog)openWindow.Content).FindResource("StandardCheckBoxTemplate") as DataTemplate);
 }
示例#32
0
        internal void ReadContentFrom(XmlReader r)
        {
            if (r.ReadState != ReadState.Interactive)
            {
                throw new InvalidOperationException(SR.InvalidOperation_ExpectedInteractive);
            }
            XContainer     c      = this;
            NamespaceCache eCache = new NamespaceCache();
            NamespaceCache aCache = new NamespaceCache();

            do
            {
                switch (r.NodeType)
                {
                case XmlNodeType.Element:
                    XElement e = new XElement(eCache.Get(r.NamespaceURI).GetName(r.LocalName));
                    if (r.MoveToFirstAttribute())
                    {
                        do
                        {
                            e.AppendAttributeSkipNotify(new XAttribute(aCache.Get(r.Prefix.Length == 0 ? string.Empty : r.NamespaceURI).GetName(r.LocalName), r.Value));
                        } while (r.MoveToNextAttribute());
                        r.MoveToElement();
                    }
                    c.AddNodeSkipNotify(e);
                    if (!r.IsEmptyElement)
                    {
                        c = e;
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (c.content == null)
                    {
                        c.content = string.Empty;
                    }
                    if (c == this)
                    {
                        return;
                    }
                    c = c.parent;
                    break;

                case XmlNodeType.Text:
                case XmlNodeType.SignificantWhitespace:
                case XmlNodeType.Whitespace:
                    c.AddStringSkipNotify(r.Value);
                    break;

                case XmlNodeType.CDATA:
                    c.AddNodeSkipNotify(new XCData(r.Value));
                    break;

                case XmlNodeType.Comment:
                    c.AddNodeSkipNotify(new XComment(r.Value));
                    break;

                case XmlNodeType.ProcessingInstruction:
                    c.AddNodeSkipNotify(new XProcessingInstruction(r.Name, r.Value));
                    break;

                case XmlNodeType.DocumentType:
                    c.AddNodeSkipNotify(new XDocumentType(r.LocalName, r.GetAttribute("PUBLIC"), r.GetAttribute("SYSTEM"), r.Value));
                    break;

                case XmlNodeType.EntityReference:
                    if (!r.CanResolveEntity)
                    {
                        throw new InvalidOperationException(SR.InvalidOperation_UnresolvedEntityReference);
                    }
                    r.ResolveEntity();
                    break;

                case XmlNodeType.EndEntity:
                    break;

                default:
                    throw new InvalidOperationException(SR.Format(SR.InvalidOperation_UnexpectedNodeType, r.NodeType));
                }
            } while (r.Read());
        }
示例#33
0
 public XNodeWriter(XContainer fragment)
 {
     root    = fragment;
     state   = XmlNodeType.None;
     current = fragment;
 }
示例#34
0
        internal void ReadContentFrom(XmlReader r, LoadOptions o)
        {
            if ((o & (LoadOptions.SetBaseUri | LoadOptions.SetLineInfo)) == 0)
            {
                ReadContentFrom(r);
                return;
            }
            if (r.ReadState != ReadState.Interactive)
            {
                throw new InvalidOperationException(SR.InvalidOperation_ExpectedInteractive);
            }
            XContainer     c       = this;
            XNode          n       = null;
            NamespaceCache eCache  = new NamespaceCache();
            NamespaceCache aCache  = new NamespaceCache();
            string         baseUri = (o & LoadOptions.SetBaseUri) != 0 ? r.BaseURI : null;
            IXmlLineInfo   li      = (o & LoadOptions.SetLineInfo) != 0 ? r as IXmlLineInfo : null;

            do
            {
                string uri = r.BaseURI;
                switch (r.NodeType)
                {
                case XmlNodeType.Element:
                {
                    XElement e = new XElement(eCache.Get(r.NamespaceURI).GetName(r.LocalName));
                    if (baseUri != null && baseUri != uri)
                    {
                        e.SetBaseUri(uri);
                    }
                    if (li != null && li.HasLineInfo())
                    {
                        e.SetLineInfo(li.LineNumber, li.LinePosition);
                    }
                    if (r.MoveToFirstAttribute())
                    {
                        do
                        {
                            XAttribute a = new XAttribute(aCache.Get(r.Prefix.Length == 0 ? string.Empty : r.NamespaceURI).GetName(r.LocalName), r.Value);
                            if (li != null && li.HasLineInfo())
                            {
                                a.SetLineInfo(li.LineNumber, li.LinePosition);
                            }
                            e.AppendAttributeSkipNotify(a);
                        } while (r.MoveToNextAttribute());
                        r.MoveToElement();
                    }
                    c.AddNodeSkipNotify(e);
                    if (!r.IsEmptyElement)
                    {
                        c = e;
                        if (baseUri != null)
                        {
                            baseUri = uri;
                        }
                    }
                    break;
                }

                case XmlNodeType.EndElement:
                {
                    if (c.content == null)
                    {
                        c.content = string.Empty;
                    }
                    // Store the line info of the end element tag.
                    // Note that since we've got EndElement the current container must be an XElement
                    XElement e = c as XElement;
                    Debug.Assert(e != null, "EndElement recieved but the current container is not an element.");
                    if (e != null && li != null && li.HasLineInfo())
                    {
                        e.SetEndElementLineInfo(li.LineNumber, li.LinePosition);
                    }
                    if (c == this)
                    {
                        return;
                    }
                    if (baseUri != null && c.HasBaseUri)
                    {
                        baseUri = c.parent.BaseUri;
                    }
                    c = c.parent;
                    break;
                }

                case XmlNodeType.Text:
                case XmlNodeType.SignificantWhitespace:
                case XmlNodeType.Whitespace:
                    if ((baseUri != null && baseUri != uri) ||
                        (li != null && li.HasLineInfo()))
                    {
                        n = new XText(r.Value);
                    }
                    else
                    {
                        c.AddStringSkipNotify(r.Value);
                    }
                    break;

                case XmlNodeType.CDATA:
                    n = new XCData(r.Value);
                    break;

                case XmlNodeType.Comment:
                    n = new XComment(r.Value);
                    break;

                case XmlNodeType.ProcessingInstruction:
                    n = new XProcessingInstruction(r.Name, r.Value);
                    break;

                case XmlNodeType.DocumentType:
                    n = new XDocumentType(r.LocalName, r.GetAttribute("PUBLIC"), r.GetAttribute("SYSTEM"), r.Value);
                    break;

                case XmlNodeType.EntityReference:
                    if (!r.CanResolveEntity)
                    {
                        throw new InvalidOperationException(SR.InvalidOperation_UnresolvedEntityReference);
                    }
                    r.ResolveEntity();
                    break;

                case XmlNodeType.EndEntity:
                    break;

                default:
                    throw new InvalidOperationException(SR.Format(SR.InvalidOperation_UnexpectedNodeType, r.NodeType));
                }
                if (n != null)
                {
                    if (baseUri != null && baseUri != uri)
                    {
                        n.SetBaseUri(uri);
                    }
                    if (li != null && li.HasLineInfo())
                    {
                        n.SetLineInfo(li.LineNumber, li.LinePosition);
                    }
                    c.AddNodeSkipNotify(n);
                    n = null;
                }
            } while (r.Read());
        }