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


C# XContainer.Element方法代碼示例

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


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

示例1: Populate

        public override void Populate(XContainer root)
        {
            root = root.Element("result");

            base.Populate(root);

            Url = root.Element("url").Value;
        }
開發者ID:cloudsponge,項目名稱:cloudsponge-lib-net,代碼行數:8,代碼來源:ConsentResponse.cs

示例2: GetAccount

        private static IAccount GetAccount(XContainer accountContainer)
        {
            if (accountContainer == null) return null;

            return new Account
            {
                Number = accountContainer.Element("Number").GetTextValue(),
                CountryCode = accountContainer.Element("CountryCode").GetTextValue()
            };
        }
開發者ID:alexander-yushchenko,項目名稱:ExpressConnect,代碼行數:10,代碼來源:TrackResponseParserHelpers.cs

示例3: UpdatePropertyElement

        /// <summary>
        /// Updates the property element.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="elementPosition">The element position.</param>
        /// <param name="fileId">The file id.</param>
        private static void UpdatePropertyElement(XContainer property, SourceElementPosition elementPosition, string fileId)
        {
            property.Add(new XElement("FileRef", new XAttribute("uid", fileId)));

            var seqpnt = new XElement(
                "SequencePoint",
                new XAttribute("vc", property.Element("MethodPoint").Attribute("vc").Value),
                new XAttribute("sl", elementPosition.Start));

            property.Element("SequencePoints").Add(seqpnt);
        }
開發者ID:marto83,項目名稱:Aqueduct.SpecDashboard,代碼行數:17,代碼來源:OpenCoverReportPreprocessor.cs

示例4: BuildUserInfo

 private static UserInfo BuildUserInfo(XContainer user)
 {
     // ReSharper disable PossibleNullReferenceException
     return new UserInfo
                {
                    Name = user.Element("screen_name").Value,
                    Location = user.Element("location").Value,
                    FriendCount = int.Parse(user.Element("friends_count").Value),
                    FollowerCount = int.Parse(user.Element("followers_count").Value)
                };
     // ReSharper restore PossibleNullReferenceException
 }
開發者ID:trasa,項目名稱:TwitDegrees,代碼行數:12,代碼來源:StatusService.cs

示例5: WufooData

 /// <summary>
 /// Constructor for user data 
 /// </summary>
 /// <param name="xml">XContainer containing user data</param>
 /// <param name="adminUser">Admin username</param>
 public WufooData(XContainer xml, string adminUser)
 {
     // set user properties
     AdminUserName = adminUser;
     Hash = xml.Element("Hash").ElementValueNull();
     Title = xml.Element("User").ElementValueNull();
     ApiKey = xml.Element("ApiKey").ElementValueNull();
     FormsUrl = xml.Element("LinkForms").ElementValueNull();
     CreateForms = xml.Element("CreateForms").ElementValueNull().Equals("1");
     Created = DateTime.MinValue;
     Modified = DateTime.MinValue;
     IsForm = false;
 }
開發者ID:SGAnonymous,項目名稱:sdl-tridion-world,代碼行數:18,代碼來源:WufooData.cs

示例6: Station

 public Station(XContainer xc)
 {
     name = xc.Element("name").Value;
     id = Convert.ToInt32(xc.Element("id").Value);
     lat = Convert.ToDouble(xc.Element("lat").Value);
     lng = Convert.ToDouble(xc.Element("long").Value);
     installed = Convert.ToBoolean(xc.Element("installed").Value);
     locked = Convert.ToBoolean(xc.Element("locked").Value);
     locked = Convert.ToBoolean(xc.Element("temporary").Value);
     bikeCount = Convert.ToInt32(xc.Element("nbBikes").Value);
     dockCount = Convert.ToInt32(xc.Element("nbEmptyDocks").Value);
 }
開發者ID:kylehill,項目名稱:cabi,代碼行數:12,代碼來源:Station.cs

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

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

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

示例10: GetValue

        private static string GetValue(XContainer container, string elementName)
        {
            var typeElemment = container.Element(elementName);
            if (typeElemment == null)
                throw new ArgumentException("找不到元素 MsgType。");

            return typeElemment.Value;
        }
開發者ID:newlysoft,項目名稱:WeiXinSDK-1,代碼行數:8,代碼來源:EventRequestMessageFormatter.cs

示例11: UpdatePropertyElement

 /// <summary>
 /// Updates the property element.
 /// </summary>
 /// <param name="property">The property.</param>
 /// <param name="elementPosition">The element position.</param>
 /// <param name="fileId">The file id.</param>
 private static void UpdatePropertyElement(XContainer property, SourceElementPosition elementPosition, string fileId)
 {
     foreach (var pt in property.Element("code").Elements().Take(1))
     {
         pt.Add(new XAttribute("sl", elementPosition.Start));
         pt.Add(new XAttribute("fid", fileId));
     }
 }
開發者ID:tigerjibo,項目名稱:ReportGenerator,代碼行數:14,代碼來源:PartCover22ReportPreprocessor.cs

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

示例13: RegisterExecutionTypes

 private void RegisterExecutionTypes(XContainer root, OpcodeLookup lookup)
 {
     foreach (XElement element in root.Element("scriptTypes").Descendants("type"))
     {
         var opcode = (ushort) XMLUtil.GetNumericAttribute(element, "opcode");
         string name = XMLUtil.GetStringAttribute(element, "name");
         lookup.RegisterScriptType(name, opcode);
     }
 }
開發者ID:t3hm00kz,項目名稱:Assembly,代碼行數:9,代碼來源:XMLOpcodeLookup.cs

示例14: FillProperties

        public void FillProperties(XContainer xml)
        {
            if (xml == null) return;

            var title = xml.Element("title");
            var phone = xml.Element("phone");
            var fax = xml.Element("fax");
            var email = xml.Element("email");
            var visitingAddress = xml.Element("visitingaddress");
            var address = xml.Element("address");

            if (title != null) Title = string.IsNullOrEmpty(title.Value) ? null : title.Value;
            if (phone != null) Phone = string.IsNullOrEmpty(phone.Value) ? null : phone.Value;
            if (fax != null) Fax = string.IsNullOrEmpty(fax.Value) ? null : fax.Value;
            if (email != null) Email = string.IsNullOrEmpty(email.Value) ? null : email.Value;
            if (visitingAddress != null) VisitingAddress = string.IsNullOrEmpty(visitingAddress.Value) ? null : visitingAddress.Value;
            if (address != null) Address = string.IsNullOrEmpty(address.Value) ? null : address.Value;

            var contactPersons = xml.Element("contact-persons");
            
            if (contactPersons != null)
            {
                ContactPersons = new List<ContactPerson>();

                foreach (var person in contactPersons.Descendants("person"))
                {
                    var name = person.Element("name");
                    if (name == null) continue;
                    if (string.IsNullOrEmpty(name.Value)) continue;
                    var cp = new ContactPerson {Name = name.Value};
                
                    var positionAsElement = person.Element("position");
                    var emailAsElement = person.Element("email");
                    var phoneAsElement = person.Element("phone");

                    if (positionAsElement != null && !string.IsNullOrEmpty(positionAsElement.Value))
                        cp.Position = positionAsElement.Value;
                    if (emailAsElement != null && !string.IsNullOrEmpty(emailAsElement.Value))
                        cp.Email = emailAsElement.Value;
                    if (phoneAsElement != null && !string.IsNullOrEmpty(phoneAsElement.Value))
                        cp.Phone = phoneAsElement.Value;

                    ContactPersons.Add(cp);
                }
            }

            var genericFields = xml.Element("generic-fields");
            if (genericFields == null) return;
            GenericFields = new List<string>();
            var fields = genericFields.Descendants("field");
            foreach (var field in fields.Where(field => field != null && !string.IsNullOrEmpty(field.Value))){
                GenericFields.Add(field.Value);
            }
        }
開發者ID:khellang,項目名稱:Solvberget,代碼行數:54,代碼來源:ContactInformation.cs

示例15: GetCountry

        private static ICountry GetCountry(XContainer countryContainer)
        {
            if (countryContainer == null) return null;

            return new Country
            {
                Code = countryContainer.Element("CountryCode").GetTextValue(),
                Name = countryContainer.Element("CountryName").GetTextValue()
            };
        }
開發者ID:alexander-yushchenko,項目名稱:ExpressConnect,代碼行數:10,代碼來源:TrackResponseParserHelpers.cs


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