本文整理汇总了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)
};
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例9: TokenData
public TokenData(XElement data)
: this()
{
var ns = data.GetDefaultNamespace();
this.Key = data.Element(ns + "Key").Value;
}
示例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);
}
示例11: LoadXml
public static IEnumerable<SkipItem> LoadXml(XElement element)
{
var ns = element.GetDefaultNamespace();
foreach (var child in element.Elements())
{
yield return new SkipItem(child);
}
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}