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


C# XContainer.Elements方法代碼示例

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


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

示例1: HandleEmployee

 private static Employee HandleEmployee(XContainer xml)
 {
     var m = new Employee
                 {
                     Salary = decimal.Parse(xml.Elements("Salary").First().Value),
                     Person = HandlePerson(xml.Elements("Person").FirstOrDefault())
                 };
     return m;
 }
開發者ID:nuzil,項目名稱:101repo,代碼行數:9,代碼來源:CompanyBuilder.cs

示例2: HandlePerson

        private static Person HandlePerson(XContainer xml)
        {
            var p = new Person
                        {
                            Address = xml.Elements("Address").First().Value,
                            Name = xml.Elements("Name").First().Value
                        };

            return p;
        }
開發者ID:nuzil,項目名稱:101repo,代碼行數:10,代碼來源:CompanyBuilder.cs

示例3: Post

        public Post(XContainer post)
        {
            // Get the string properties from the post's element values
            Title = getvalue(post, "title");
            Link = getvalue(post, "guid");
            Description = getvalue(post, "description");
            Creator = getvalue(post, "{http://purl.org/dc/elements/1.1/}creator");

            if (post.Elements("{http://purl.org/rss/1.0/modules/content/}encoded").Any())
                Content = post.Elements("{http://purl.org/rss/1.0/modules/content/}encoded").First().Value;
            else if (post.Elements("enclosure").Any())
                if (post.Elements("enclosure").First().Attribute("url") != null)
                    imageUrl = post.Elements("enclosure").First().Attribute("url").Value;

            if (!String.IsNullOrEmpty(Content))
            {
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(Content);
                var imgLinks = doc.DocumentNode
                             .Descendants("img")
                             .Select(n => n.Attributes["src"].Value)
                             .ToArray();
                if (imgLinks.Length > 0)
                {
                    imageUrl = imgLinks[0].ToString();
                }
            }
            /*//Content = getvalue(post, "{http://purl.org/rss/1.0/modules/content/}encoded");


            if (post.Elements("{http://purl.org/rss/1.0/modules/content/}encoded").Any())
            {

                Content = post.Elements("{http://purl.org/rss/1.0/modules/content/}encoded").First().Value;
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(Content);
                var imgLinks = doc.DocumentNode
                             .Descendants("img")
                             .Select(n => n.Attributes["src"].Value)
                             .ToArray();

                if (imgLinks.Length > 0)
                {
                    imageUrl = imgLinks[0].ToString();
                }
            }*/

            DateTime result;
            if (DateTime.TryParse(getvalue(post, "pubDate"), out result))
                pubDate = (DateTime?)result;
        }
開發者ID:esurmay,項目名稱:NewsWebSite,代碼行數:51,代碼來源:Post.cs

示例4: 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

示例5: GenerateHtmlDocuments

        static HtmlDocument[] GenerateHtmlDocuments(XContainer element)
        {
            if (element == null)
                return null;

            return element.Elements(DocumentNodeName).Select(GenerateHtmlDocument).ToArray();
        }
開發者ID:docrinehart,項目名稱:LearnAngular,代碼行數:7,代碼來源:XmlParser.cs

示例6: 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

示例7: 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

示例8: 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

示例9: ExtractFeatures

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

示例10: ChoiceParameter

        public ChoiceParameter(XContainer document)
            : base(document)
        {
            ParameterType = BuildParameterType.ChoiceParameterDefinition;

            Options = document.Elements("choice").Select(a => new NameValuePair(a.Value, a.Value)).ToArray();
        }
開發者ID:nrjohnstone,項目名稱:cctray-jenkins-transport,代碼行數:7,代碼來源:ChoiceParameter.cs

示例11: GetJoins

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

示例12: 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

示例13: 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

示例14: RSAKey

        /// <summary>
        /// Initializes a new instance of the <see cref="RSAKey" /> class.
        /// </summary>
        /// <param name="xml">The xml represention to be loaded.</param>
        /// <exception cref="System.ArgumentNullException">xml</exception>
        public RSAKey(XContainer xml)
        {
            if(xml == null)
            {
                throw new ArgumentNullException("xml");
            }

            XElement elem;
            if((elem = xml.Elements("Private").FirstOrDefault()) != null)
            {
                Private = elem.Value;
            }
            if((elem = xml.Elements("Public").FirstOrDefault()) != null)
            {
                Public = elem.Value;
            }
        }
開發者ID:NatashaSchutte,項目名稱:Warewolf-ESB,代碼行數:22,代碼來源:RSAKey.cs

示例15: DeleteItems

        private static void DeleteItems(XContainer items)
        {
            foreach (var element in items.Elements())
            {
                var database = Factory.GetDatabase(element.GetAttributeValue("database"));

                var obj = database?.GetItem(element.GetAttributeValue("id"));
                obj?.Delete();
            }
        }
開發者ID:GuitarRich,項目名稱:Console,代碼行數:10,代碼來源:PackagePostStep.cs


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