本文整理汇总了C#中System.Xml.Linq.XElement.Get方法的典型用法代码示例。如果您正苦于以下问题:C# XElement.Get方法的具体用法?C# XElement.Get怎么用?C# XElement.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XElement
的用法示例。
在下文中一共展示了XElement.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: uses_the_default_value
public void uses_the_default_value()
{
var element = new XElement("PropertyGroup");
element.Add(new XElement("TargetFrameworkVersion", "v4.0"));
element.Get("AssemblyName", "ClassLibrary1").ShouldEqual("ClassLibrary1");
}
示例2: User
internal User( WebAgent agent, XElement user )
{
this.agent = agent;
this.username = user.Get( "user_name" );
this.defaultFormat = user.Get( "user_format_short" );
this.defaultExpiration = user.Get( "user_expiration" );
this.avatarUrl = user.Get( "user_avatar_url" );
this.website = user.Get( "user_website" );
this.email = user.Get( "user_email" );
this.location = user.Get( "user_location" );
this.defaultExposure = user.Get<PasteExposure, int>( "user_private", Int32.Parse );
this.accountType = user.Get<AccountType, int>( "user_account_type", Int32.Parse );
}
示例3: TVDBEpisode
public TVDBEpisode(XElement element)
{
ID = element.GetInt("id").Value;
Directors = element.Split("Director");
Name = element.Get("EpisodeName");
Number = element.GetInt("EpisodeNumber").Value;
Aired = element.GetDateTime("FirstAired");
GuestStars = element.Split("GuestStars");
IMDbID = element.Get("IMDB_ID");
Language = element.Get("Language");
Overview = element.Get("Overview");
Season = element.GetInt("SeasonNumber").Value;
Writers = element.Split("Writer");
AbsoluteNumber = element.GetInt("absolute_number");
Filename = element.Get("filename");
LastUpdated = element.GetUnixDateTime("lastupdated");
SeasonID = element.GetInt("seasonid").Value;
SeriesID = element.GetInt("seriesid").Value;
Rating = element.GetDouble("Rating");
}
示例4: Metrics
public static Metrics Metrics(XElement typeNode)
{
var memberMetrics = typeNode.Descendants("Member")
.Where(IsNotGenerated)
.SelectMany(node => node.Descendants("Metric"));
var metricsMetaData = new Metrics();
metricsMetaData[TypeName] = typeNode.Get(Name);
metricsMetaData[LinesPerMethod] = MemberToxicityFor(LinesOfCode, threasholdLimits[LinesPerMethod], memberMetrics).ToString();
metricsMetaData[ComplexityPerMethod] = MemberToxicityFor(CyclomaticComplexity, threasholdLimits[CyclomaticComplexity], memberMetrics).ToString();
metricsMetaData[CouplingPerMethod] = MemberToxicityFor(ClassCoupling, threasholdLimits[ClassCoupling], memberMetrics).ToString();
return metricsMetaData.ToDictionary();
}
示例5: _getValue
private object _getValue(XElement element) {
if (element.HasAttribute("value")) {
return element.Get("value");
}
if (!element.HasElements) {
return element.Value;
}
var valueSet = new Dictionary<string, string>();
foreach (var child in element.Elements()) {
var itemTag = child.Name.LocalName;
if (itemTag != "Value") {
throw new Exception("Unrecognized tag '{0}'".Substitute(itemTag));
}
valueSet.Add(child.Get("name"), child.HasAttribute("value") ? child.Get("value") : child.Value);
}
return valueSet;
}
示例6: Get_StringValue
public void Get_StringValue()
{
string value = "A value to test";
XElement test = new XElement("Node", value);
string result = test.Get("", "");
Assert.AreEqual(string.Compare(value, result), 0);
}
示例7: Get_IntValue
public void Get_IntValue()
{
int value = 100;
XElement test = new XElement("Node", value);
int result = test.Get("", 0);
Assert.AreEqual(value, result);
}
示例8: Get_IntAttribute
public void Get_IntAttribute()
{
int value = 100;
XElement test = new XElement("Node", new XAttribute("A", value));
int result = test.Get("A", 0);
Assert.AreEqual(value, result);
}
示例9: IsNotGenerated
public static bool IsNotGenerated(XElement node)
{
if (node.Attribute("File") == null) return true;
return !generatedFiles.Contains(node.Get("File").ToLower());
}
示例10: FromXmlOverride
/// <summary>Override this method on derived script nodes to convert the node to XML.</summary>
protected virtual void FromXmlOverride(XElement element) {
SourceCode = element.Value;
Title = element.Get("title");
}
示例11: ParseXmlOverride
/// <summary>Parses the descriptor properties from the given XML object.</summary>
/// <param name="element">The XML element to parse.</param>
protected virtual void ParseXmlOverride(XElement element) {
_bookmark = element.Get("Bookmark");
_details = element.Get("Details");
_help = element.Get("Help");
_isEnabled = element.Get<bool>("IsEnabled", true);
_isVisible = element.Get<bool>("IsVisible", true);
_icon = element.Get("Icon");
_rating = element.Get<int>("Rating", 0).Limit(0,10);
_subject = element.Get("Subject");
_text = element.Get("Text");
}
示例12: FromXmlOverride
/// <summary/>
protected override void FromXmlOverride(XElement element) {
base.FromXmlOverride(element);
if (element.HasAttribute("operation")) {
Operation = BplClass.Get(element.Get("operation"));
}
}
示例13: Paste
internal Paste( WebAgent agent, XElement paste )
{
this.agent = agent;
this.key = paste.Get( "paste_key" );
this.timestamp = paste.Get( "paste_date", Int32.Parse );
this.title = paste.Get( "paste_title" );
this.size = paste.Get( "paste_size", Int32.Parse );
this.expireTimestamp = paste.Get( "paste_expire_date", Int32.Parse );
this.exposure = paste.Get<PasteExposure, int>( "paste_private", Int32.Parse );
this.formatName = paste.HasValueFor( "paste_format_long" ) ? paste.Get( "paste_format_long" ) : null;
this.formatId = paste.HasValueFor( "paste_format_short" ) ? paste.Get( "paste_format_short" ) : null;
this.url = paste.Get( "paste_url" );
this.views = paste.Get( "paste_hits", Int32.Parse );
}
示例14: ParseXmlOverride
/// <summary>Parses the error message properties from the given XML object.</summary>
/// <param name="element">The XML element to parse.</param>
protected virtual void ParseXmlOverride(XElement element) {
Details = element.Get("Details");
ErrorCode = element.Get("ErrorCode");
Help = element.Get("Help");
Severity = element.Get<Severity>("Severity", Severity.Info);
Text = element.Get("Text");
}
示例15: ParseXmlOverride
/// <summary/>
protected override void ParseXmlOverride(XElement element) {
base.ParseXmlOverride(element);
IsExpanded = element.Get<bool>("IsExpanded");
}