本文整理汇总了C#中System.Xml.Linq.XElement.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# XElement.GetValue方法的具体用法?C# XElement.GetValue怎么用?C# XElement.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XElement
的用法示例。
在下文中一共展示了XElement.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillObjectData
/// <summary>
/// Fills the object data.
/// </summary>
/// <param name="xml">The XML.</param>
protected override void FillObjectData(XElement xml)
{
base.FillObjectData(xml);
this.Event =xml.GetValue( nodeName_Event);
this.EventKey =xml.GetValue( nodeName_EventKey);
}
示例2: FillObjectData
/// <summary>
/// Fills the object data.
/// </summary>
/// <param name="xml">The XML.</param>
protected override void FillObjectData(XElement xml)
{
base.FillObjectData(xml);
this.Url = xml.GetValue(nodeName_Url);
this.Title = xml.GetValue(nodeName_Title);
this.Description = xml.GetValue(nodeName_Description);
}
示例3: FromXml
public static Argument FromXml(XElement container)
{
if (container == null)
{
throw new ArgumentNullException("container");
}
return new Argument
{
Name = container.GetValue(uPnpNamespaces.svc + "name"),
Direction = container.GetValue(uPnpNamespaces.svc + "direction"),
RelatedStateVariable = container.GetValue(uPnpNamespaces.svc + "relatedStateVariable")
};
}
示例4: MetaListItemInfo
public MetaListItemInfo(XElement node)
{
if (node == null)
throw new ArgumentNullException("node");
_path = node.GetValue("id");
_parent = node.GetValue("parent_id");
_modified = node.GetValue("updated_time");
_isDir = node.GetValue("type") == "folder";
Title = node.GetValue("name");
Notes = GetRelativeTime(_modified);
Icon = ThemeData.GetImage(_isDir
? "folder" : "entry");
}
示例5: MakeReportNode
public static bool MakeReportNode(XElement source, bool? compatibleValue=false)
{
if ((source.GetValue("Compatible")!=null && compatibleValue==null) ||
(source.GetValue("Compatible") == compatibleValue.ToString().ToLowerInvariant()))
{
source.Elements().Where(e => e.Name != "Parameter" && e.Name != "Accessor").Remove();
return true;
}
if (!source.HasElements)
return false;
source.Elements().Where(e => !MakeReportNode(e,compatibleValue)).Remove();
return source.HasElements;
}
示例6: Create
public static uBaseObject Create(XElement container)
{
if (container == null)
{
throw new ArgumentNullException("container");
}
return new uBaseObject
{
Id = container.GetAttributeValue(uPnpNamespaces.Id),
ParentId = container.GetAttributeValue(uPnpNamespaces.ParentId),
Title = container.GetValue(uPnpNamespaces.title),
IconUrl = container.GetValue(uPnpNamespaces.Artwork),
UpnpClass = container.GetValue(uPnpNamespaces.uClass)
};
}
示例7: AreCompatible
//One generic compatibility check for all. Needed for reports and stuff
public static bool AreCompatible(XElement first, XElement second)
{
//get method parameters
IEnumerable<string> params1 = first.Elements("Parameter").Select(m => m.Attribute("Type").Value).ToArray();
IEnumerable<string> params2 = second.Elements("Parameter").Select(m => m.Attribute("Type").Value).ToArray();
//TODO: optimization?
return
//whatever: check tag names
first.Name.LocalName == second.Name.LocalName &&
//whatever: check names
first.GetValue("Name") == second.GetValue("Name") &&
//whatever: static or not
first.GetValue("Static") == second.GetValue("Static") &&
//classes: path
first.GetValue("Path") == second.GetValue("Path") &&
//classes: abstract or not
first.GetValue("Abstract") == second.GetValue("Abstract") &&
//fields&properties: check type
first.GetValue("Type") == second.GetValue("Type") &&
//methods: check return type
first.GetValue("ReturnType") == second.GetValue("ReturnType") &&
//enums: check value
first.GetValue("Value") == second.GetValue("Value") &&
//methods: check parameters
Enumerable.SequenceEqual(params1, params2) &&
//Check properties Accessors
first.Elements("Accessor").All(m => second.Elements("Accessor").Any(n => AreCompatible(m, n)));
}
示例8: Empty_value_returns_default_type
public void Empty_value_returns_default_type()
{
var element = new XElement("foo", "");
int expected = 0;
var actual = element.GetValue<int>();
Assert.AreEqual(expected, actual);
}
示例9: Value_of_element_is_returned_of_type_according_to_generic_invocation
public void Value_of_element_is_returned_of_type_according_to_generic_invocation()
{
var element = new XElement("foo", "42");
double expected = 42;
var actual = element.GetValue<double>();
Assert.AreEqual(expected, actual);
}
示例10: Create
public static uBaseObject Create(XElement container)
{
if (container == null)
{
throw new ArgumentNullException("container");
}
return new uBaseObject
{
Id = container.Attribute(uPnpNamespaces.Id).Value,
ParentId = container.Attribute(uPnpNamespaces.ParentId).Value,
Title = container.GetValue(uPnpNamespaces.title),
IconUrl = container.GetValue(uPnpNamespaces.Artwork),
SecondText = "",
Url = container.GetValue(uPnpNamespaces.Res),
ProtocolInfo = GetProtocolInfo(container),
MetaData = container.ToString()
};
}
示例11: FromXml
public static StateVariable FromXml(XElement container)
{
var allowedValues = new List<string>();
var element = container.Descendants(uPnpNamespaces.svc + "allowedValueList")
.FirstOrDefault();
if (element != null)
{
var values = element.Descendants(uPnpNamespaces.svc + "allowedValue");
allowedValues.AddRange(values.Select(child => child.Value));
}
return new StateVariable
{
Name = container.GetValue(uPnpNamespaces.svc + "name"),
DataType = container.GetValue(uPnpNamespaces.svc + "dataType"),
AllowedValues = allowedValues
};
}
示例12: MetaListItemInfo
public MetaListItemInfo(XElement node)
{
if (node == null)
throw new ArgumentNullException("node");
_path = node.GetValue("id");
_parent = node.GetValue("parent_id");
_modified = node.GetValue("updated_time");
var type = node.GetValue("type");
if(string.IsNullOrEmpty(type))
{
type = "file";
}
_isDir = "folder|album".Contains(type); // Show folder icon in case of folder/album
int.TryParse(node.GetValue("size"), out _size);
Title = node.GetValue("name") ?? "";
Notes = GetRelativeTime(_modified);
string iconStr = "";
iconStr = Title.EndsWith(".kdbx",StringComparison.InvariantCultureIgnoreCase) // If its keepass database
? "keepasslogo"
: (_isDir
? "folder"
: "entry");
Icon = ThemeData.GetImage(iconStr);
}
示例13: ApplyPatch
public static void ApplyPatch(XElement source, XElement patch)
{
if (patch == null)
return;
source.SetAttributeValue("Compatible", patch.GetValue("Compatible"));
foreach (XElement element in source.Elements().ExceptAccessorsAndParameters())
{
ApplyPatch(element, patch.Elements(element.Name.LocalName).
ExceptAccessorsAndParameters().SingleOrDefault(e => Check.AreCompatible(element, e)));
}
}
示例14: FromXml
public static ServiceAction FromXml(XElement container)
{
var argumentList = new List<Argument>();
foreach (var arg in container.Descendants(uPnpNamespaces.svc + "argument"))
{
argumentList.Add(Argument.FromXml(arg));
}
return new ServiceAction
{
Name = container.GetValue(uPnpNamespaces.svc + "name"),
ArgumentList = argumentList
};
}
示例15: MetaListItemInfo
public MetaListItemInfo(XElement node)
{
if (node == null)
throw new ArgumentNullException("node");
_path = node.GetValue("id");
_parent = node.GetValue("parent_id");
_modified = node.GetValue("updated_time");
_isDir = "folder|album".Contains(node.GetValue("type")); // Show folder icon in case of folder/album
int.TryParse(node.GetValue("size"), out _size);
Title = node.GetValue("name");
Notes = GetRelativeTime(_modified);
string iconStr = "";
iconStr = Title.EndsWith(".kdbx") // If its keepass database
? "keepasslogo"
: (_isDir
? "folder"
: "entry");
Icon = ThemeData.GetImage(iconStr);
}