当前位置: 首页>>代码示例>>C#>>正文


C# XElement.GetDefaultNamespace方法代码示例

本文整理汇总了C#中System.Xml.Linq.XElement.GetDefaultNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# XElement.GetDefaultNamespace方法的具体用法?C# XElement.GetDefaultNamespace怎么用?C# XElement.GetDefaultNamespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Linq.XElement的用法示例。


在下文中一共展示了XElement.GetDefaultNamespace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deserialize

        internal static Blogger Deserialize(XElement element)
        {
            if (element == null)
            {
                return null;
            }

            var ns = element.GetDefaultNamespace();
            var id = element.Element(ns + "id");
            var title = element.Element(ns + "title");
            var updated = element.Element(ns + "updated");
            var href = element.Element(ns + "link")?.Attribute("href");
            var blogapp = element.Element(ns + "blogapp");
            var avatar = element.Element(ns + "avatar");
            var postcount = element.Element(ns + "postcount");

            if (id == null || title == null || updated == null || href == null || blogapp == null || avatar == null || postcount == null)
            {
                return null;
            }

            return new Blogger
            {
                Id = new Uri(id.Value, UriKind.Absolute),
                Title = title.Value,
                Updated = DateTime.Parse(updated.Value, CultureInfo.InvariantCulture),
                Link = new Uri(href.Value, UriKind.Absolute),
                BlogApp = blogapp.Value,
                Avatar = avatar.IsEmpty ? null : new Uri(avatar.Value, UriKind.Absolute),
                PostCount = int.Parse(postcount.Value, CultureInfo.InvariantCulture)
            };
        }
开发者ID:jango2015,项目名称:SoftwareKobo.CnblogsAPI,代码行数:32,代码来源:BloggerHelper.cs

示例2: IdentityEntityProperties

 public IdentityEntityProperties(XElement parent, PropertyExtensionContext context)
 {
     this.propertyManager = new PropertyManager(parent.GetDefaultNamespace());
     this.context = context;
     this.parent = parent;
     this.parent.Changed += parentChanged;
 }
开发者ID:mlzharov,项目名称:Asp.Net-Identity-Tools-for-Entity-Framework-model,代码行数:7,代码来源:IdentityEntityProperties.cs

示例3: GetItemAuthor

        private static string GetItemAuthor(XElement item)
        {
            var content = string.Empty;

            if (item != null && !string.IsNullOrEmpty(item.Element(item.GetDefaultNamespace() + "author").Value))
            {
                content = item.Element(item.GetDefaultNamespace() + "author").GetSafeElementString("name");
            }

            if (string.IsNullOrEmpty(content))
            {
                content = item.GetSafeElementString("author");
            }

            return content;
        }
开发者ID:rodrigorodriguessilva,项目名称:ContosoApp,代码行数:16,代码来源:AtomParser.cs

示例4: Deserialize

        internal static ArticleAuthor Deserialize(XElement element)
        {
            if (element == null)
            {
                return null;
            }

            var ns = element.GetDefaultNamespace();
            var name = element.Element(ns + "name");
            var uri = element.Element(ns + "uri");
            var avatar = element.Element(ns + "avatar");

            if (name == null || uri == null)
            {
                return null;
            }

            var articleAuthor = new ArticleAuthor
            {
                Name = name.Value,
                Uri = new Uri(uri.Value, UriKind.Absolute)
            };
            if (avatar != null && avatar.IsEmpty == false)
            {
                articleAuthor.Avator = new Uri(avatar.Value, UriKind.Absolute);
            }
            return articleAuthor;
        }
开发者ID:jango2015,项目名称:SoftwareKobo.CnblogsAPI,代码行数:28,代码来源:ArticleAuthorHelper.cs

示例5: GetXName

 public XName GetXName(XElement elem, string reference)
 {
     string[] parts = reference.Split(':');
     if (parts.Length == 2)
     {
         XNamespace ns = elem.GetNamespaceOfPrefix(parts[0]);
         if (ns != null)
         {
             return ns + parts[1];
         }
         else
         {
             this.Importer.Diagnostics.AddError("Invalid namespace prefix: " + parts[0], this.Uri, this.GetTextSpan(elem));
             return null;
         }
     }
     else if (parts.Length == 1)
     {
         XNamespace ns = elem.GetDefaultNamespace();
         return ns + parts[0];
     }
     else
     {
         return null;
     }
 }
开发者ID:Bubesz,项目名称:soal-cs,代码行数:26,代码来源:XmlReader.cs

示例6: GetLayerList

        public static string[] GetLayerList(XElement xEle)
        {
            List<string> lst = new List<string>();
            XNamespace aw = xEle.GetDefaultNamespace();
            IEnumerable<XElement> de = from el in xEle.Descendants(aw + "Layer") select el;

            foreach (XElement el in de)
            {
                if (el.Elements(aw + "Name").Count() > 0)
                {
                    lst.Add(el.Elements(aw + "Name").First().Value);
                }
            }

            if (lst.Count() > 0)
            {
                string[] lyrList = new string[lst.Count];

                for (int i = 0; i < lst.Count; i++)
                {
                    lyrList[i] = lst[i];
                }
                return lyrList;
            }
            return null;
        }
开发者ID:k4th,项目名称:geoportal-server,代码行数:26,代码来源:LinqXmlHelper.cs

示例7: LoadMPD

        public static MPD LoadMPD(XElement element)
        {
            var ns = element.GetDefaultNamespace().NamespaceName;
            var result = new MPD();

            result.Id = (string)element.Attribute("id");
            result.Profiles = (string)element.Attribute("profiles");
            result.Type = element.Attribute("type").GetEnum<Presentation>();
            result.AvailabilityStartTime = element.Attribute("availabilityStartTime").GetNullableDateTime();
            result.AvailabilityEndTime = element.Attribute("availabilityEndTime").GetNullableDateTime();
            result.MediaPresentationDuration = element.Attribute("mediaPresentationDuration").GetNullableDuration();
            result.MinimumUpdatePeriod = element.Attribute("minimumUpdatePeriod").GetNullableDuration();
            result.MinBufferTime = element.Attribute("minBufferTime").GetNullableDuration();
            result.TimeShiftBufferDepth = element.Attribute("timeShiftBufferDepth").GetNullableDuration();
            result.SuggestedPresentationDelay = element.Attribute("suggestedPresentationDelay").GetNullableDuration();
            result.MaxSegmentDuration = element.Attribute("maxSegmentDuration").GetNullableDuration();
            result.MaxSubsegmentDuration = element.Attribute("maxSubsegmentDuration").GetNullableDuration();
            result.AnyAttr.AddRange(element.Attributes());

            result.ProgramInformation.AddRange(element.Elements(XName.Get("ProgramInformation", ns)).Select(LoadProgramInformation));
            result.BaseURL.AddRange(element.Elements(XName.Get("BaseURL", ns)).Select(LoadBaseURL));
            result.Location.AddRange(element.Elements(XName.Get("Location", ns)).Select(e => e.Value));
            result.Period.AddRange(element.Elements(XName.Get("Period", ns)).Select(LoadPeriod));
            result.Metrics.AddRange(element.Elements(XName.Get("Metrics", ns)).Select(LoadMetrics));
            result.Any.AddRange(element.Elements());

            return result;
        }
开发者ID:bondarenkod,项目名称:pf-arm-deploy-error,代码行数:28,代码来源:MPDFactory.cs

示例8: AddReferences

        private static bool AddReferences(IList<string> files, XElement itemGroupElement, string sourceFolder, bool needsExtending)
        {
            var xmlNamespace = itemGroupElement.GetDefaultNamespace();
            var fileAdded = false;

            if (needsExtending)
            {
                files = files.Select(x => string.Format("{0}{1}", x, Program.NEEDS_EXTENDING_EXTENSION)).ToList();
            }

            foreach (var file in files)
            {
                var hasTs = itemGroupElement
                        .Descendants()
                        .Any(descendant =>
                            descendant.Attribute("Include") != null &&
                            string.Format(@"{0}\{1}.ts", sourceFolder, file) == descendant.Attribute("Include").Value);

                if (hasTs)
                {
                    continue;
                }

                fileAdded = true;

                XElement typeScriptCompileElement;
                typeScriptCompileElement = new XElement(xmlNamespace + "TypeScriptCompile");
                typeScriptCompileElement.SetAttributeValue("Include", string.Format(@"{0}\{1}.ts", sourceFolder, file));

                itemGroupElement.Add(typeScriptCompileElement);
            }

            return fileAdded;
        }
开发者ID:JonathanLydall,项目名称:Java-Transpiler-In-C-Sharp,代码行数:34,代码来源:TypeScriptProject.cs

示例9: TokenData

        public TokenData(XElement data)
            : this()
        {
            var ns = data.GetDefaultNamespace();

            this.Key = data.Element(ns + "Key").Value;
        }
开发者ID:mattruma,项目名称:epiworx-csla,代码行数:7,代码来源:TokenData.cs

示例10: CategoryData

        public CategoryData(XElement data)
            : this()
        {
            var ns = data.GetDefaultNamespace();

            this.Name = data.Element(ns + "Name").Value;
            this.IsActive = bool.Parse(data.Element(ns + "IsActive").Value);
        }
开发者ID:WhiteIsland,项目名称:epiworx,代码行数:8,代码来源:CategoryData.cs

示例11: LoadXml

			public static IEnumerable<SkipItem> LoadXml(XElement element)
			{
				var ns = element.GetDefaultNamespace();
				foreach (var child in element.Elements())
				{
					yield return new SkipItem(child);
				}
			}
开发者ID:mhusen,项目名称:Eto,代码行数:8,代码来源:SkipFilesWizard.cs

示例12: WikiPage

        public WikiPage(XElement page)
        {
            title = page.Element(page.GetDefaultNamespace() + "title").Value;
            ns = int.Parse(page.Element(page.GetDefaultNamespace() + "ns").Value);
            id = long.Parse(page.Element(page.GetDefaultNamespace() + "id").Value);

            XElement revision = page.Element(page.GetDefaultNamespace() + "revision");
            //revid = long.Parse(revision.Element(revision.GetDefaultNamespace() + "id").Value);
            //try { parentid = long.Parse(revision.Element(revision.GetDefaultNamespace() + "parentid").Value); }
            //catch { }
            timestamp = DateTime.Parse(revision.Element(revision.GetDefaultNamespace() + "timestamp").Value);
            text = revision.Element(revision.GetDefaultNamespace() + "text").Value;
            text = text.Replace("\n", "\r\n");
            tf_IDF_Vec = new TF_IDF_Vector();

            //this.page = new Page();
        }
开发者ID:ZenithWest,项目名称:Wikipedia-Clustering,代码行数:17,代码来源:WikiPage.cs

示例13: ProjectData

        public ProjectData(XElement data)
            : this()
        {
            var ns = data.GetDefaultNamespace();

            this.Name = data.Element(ns + "Name").Value;
            this.LastNote = new NoteData(data.Element(ns + "Notes").Elements(ns + "NoteData").FirstOrDefault());
            this.IsActive = bool.Parse(data.Element(ns + "IsActive").Value);
        }
开发者ID:WhiteIsland,项目名称:epiworx,代码行数:9,代码来源:ProjectData.cs

示例14: SourceData

        public SourceData(XElement data)
            : this()
        {
            var ns = data.GetDefaultNamespace();

            this.SourceId = int.Parse(data.Element(ns + "SourceId").Value);
            this.Type = data.Element(ns + "Type").Value;
            this.Name = data.Element(ns + "Name").Value;
        }
开发者ID:mattruma,项目名称:epiworx-csla,代码行数:9,代码来源:SourceData.cs

示例15: UserData

        public UserData(XElement data)
            : this()
        {
            var ns = data.GetDefaultNamespace();

            this.UserId = int.Parse(data.Element(ns + "UserId").Value);
            this.Email = data.Element(ns + "Email").Value;
            this.Name = data.Element(ns + "Name").Value;
        }
开发者ID:mattruma,项目名称:epiworx-csla,代码行数:9,代码来源:UserData.cs


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