當前位置: 首頁>>代碼示例>>C#>>正文


C# Linq.XContainer類代碼示例

本文整理匯總了C#中System.Xml.Linq.XContainer的典型用法代碼示例。如果您正苦於以下問題:C# XContainer類的具體用法?C# XContainer怎麽用?C# XContainer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XContainer類屬於System.Xml.Linq命名空間,在下文中一共展示了XContainer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DeserializeAll

        public static IEnumerable<UserSettings> DeserializeAll(XContainer container)
        {
            if (container == null)
                throw new ArgumentNullException("xml");

            return from x in container.Descendants("UserSettings") select Deserialize(x);
        }
開發者ID:baughj,項目名稱:Spark,代碼行數:7,代碼來源:UserSettingsSerializer.cs

示例2: DeserializeAll

        public static IEnumerable<ClientVersion> DeserializeAll(XContainer container)
        {
            if (container == null)
                throw new ArgumentNullException("container");

            return from x in container.Descendants("ClientVersion") select Deserialize(x);
        }
開發者ID:baughj,項目名稱:Spark,代碼行數:7,代碼來源:ClientVersionSerializer.cs

示例3: TraverseWithXDocument

        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);
                }
            }
        }
開發者ID:viktorD1m1trov,項目名稱:T-Academy,代碼行數:28,代碼來源:VeryLaggProgram.cs

示例4: ParseParameters

        //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();
        }
開發者ID:jakobehn,項目名稱:sonarlint-vs,代碼行數:28,代碼來源:ParameterLoader.cs

示例5: UpdateGeocodes

        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;
            }
        }
開發者ID:GhostPubs,項目名稱:GhostPubsMvc4,代碼行數:26,代碼來源:CommandManager.cs

示例6: LoadLayout

 /// <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;
 }
開發者ID:YxCREATURExY,項目名稱:Assembly,代碼行數:12,代碼來源:XMLLayoutLoader.cs

示例7: ParseIssues

        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;
        }
開發者ID:HippoValidator,項目名稱:W3CCssValidationClient,代碼行數:30,代碼來源:W3CCssValidator.cs

示例8: GetGuids

        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();
        }
開發者ID:StephenMcConnel,項目名稱:flexbridge,代碼行數:7,代碼來源:BaseDomainServices.cs

示例9: SetTier2Boxes

        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);
        }
開發者ID:MerrittMelker,項目名稱:Ks.Ts.SeatsSvgHydrator,代碼行數:28,代碼來源:Holland4.cs

示例10: TryParse

        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;
        }
開發者ID:saqneo,項目名稱:ReadingList,代碼行數:33,代碼來源:GoodreadsBook.cs

示例11: OrderByMinY

 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);
 }
開發者ID:MerrittMelker,項目名稱:Ks.Ts.SeatsSvgHydrator,代碼行數:7,代碼來源:XContainerReorderElementsExtensions.cs

示例12: ParseErrorsIntoResponse

		private static IntacctServiceResponse ParseErrorsIntoResponse(XContainer errorMessage)
		{
			var response = IntacctServiceResponse.Failed;
			response.AddErrors(ParseErrors(errorMessage));

			return response;
		}
開發者ID:nicocrm,項目名稱:IntacctClient,代碼行數:7,代碼來源:ResponseParser.cs

示例13: GetSubmission

 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();
 }
開發者ID:iansrobinson,項目名稱:Restbucks,代碼行數:7,代碼來源:FormsIntegrityUtility.cs

示例14: ExtractFeatures

 private void ExtractFeatures(XContainer layer)
 {
     foreach (var feature in layer.Elements())
     {
         _featureInfo.FeatureInfos.Add(ExtractFeatureElements(feature));
     }
 }
開發者ID:pauldendulk,項目名稱:Mapsui,代碼行數:7,代碼來源:GmlGetFeatureInfoParser.cs

示例15: WithConfigurationSettings

        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);
                }
            }
        }
開發者ID:enlightendesigns,項目名稱:Calamari,代碼行數:28,代碼來源:ConfigureAzureCloudServiceConvention.cs


注:本文中的System.Xml.Linq.XContainer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。