• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Linq.XContainer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Xml.Linq.XContainer的典型用法代码示例。如果您正苦于以下问题:C# XContainer类的具体用法?C# XContainer怎么用?C# XContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XContainer类属于System.Xml.Linq命名空间,在下文中一共展示了XContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: FillProperties

        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);
            }
        }
开发者ID:digbib,项目名称:Solvberget,代码行数:29,代码来源:OpeningHoursInformation.cs


示例17: GetField

 private static string GetField(XContainer el, string fieldName)
 {
     var fld = el.Element(fieldName);
     return fld != null
         ? fld.Value
         : "<Missing>";
 }
开发者ID:CBenghi,项目名称:UnnItBooster,代码行数:7,代码来源:StudentList.cs


示例18: ChecksCallsInElement

		/// <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);
				}
			}
		}
开发者ID:comdiv,项目名称:qorpent.themas,代码行数:33,代码来源:CallGeneratorsStep.cs


示例19: ParseXml

        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();
        }
开发者ID:baynezy,项目名称:SiteWarmer,代码行数:26,代码来源:XmlConfig.cs


示例20: GenerateRequest

        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();
        }
开发者ID:digbib,项目名称:Solvberget,代码行数:25,代码来源:LibraryListDynamicRepository.cs



注:本文中的System.Xml.Linq.XContainer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Linq.XDeclaration类代码示例发布时间:2022-05-26
下一篇:
C# Linq.XComment类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap