本文整理汇总了C#中XObject.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# XObject.GetType方法的具体用法?C# XObject.GetType怎么用?C# XObject.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XObject
的用法示例。
在下文中一共展示了XObject.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AreEqual
public static void AreEqual(XObject expected, XObject actual)
{
if (expected is XDocument)
{
expected = ((XDocument)expected).Root;
}
if (actual is XDocument)
{
actual = ((XDocument)actual).Root;
}
if (expected == null && actual == null)
{
return;
}
if (expected == null)
{
RaiseAssertFailure(null, actual);
return;
}
if (actual == null)
{
RaiseAssertFailure(expected, null);
return;
}
if (expected.GetType() != actual.GetType())
{
RaiseAssertFailure(expected, actual);
return;
}
AssertEqualValues(expected, actual);
}
示例2: GetPathParts
private IEnumerable<XPathPart> GetPathParts(XObject node)
{
XElement selectedElement;
if(IsElement(node))
{
selectedElement = (XElement)node;
}
else if(IsAttribute(node))
{
selectedElement = node.Parent;
}
else
{
throw new ArgumentException("Node is not an element or attribute: " + node.GetType(), nameof(node));
}
var parts = new List<XPathPart>();
var ancestorsAndSelf = selectedElement.AncestorsAndSelf().Reverse();
foreach(var ancestor in ancestorsAndSelf)
{
var part = new XPathPart();
part.Node = ancestor;
part.Predicates = ancestor.Attributes().Where(MatchesAnyFilter).ToArray();
parts.Add(part);
}
if(IsAttribute(node))
{
parts.Add(new XPathPart {Node = node});
}
return parts;
}
示例3: MakeWrapper
public static XObjectWrapper MakeWrapper(XObject obj)
{
if (obj is XAttribute)
return MakeWrapper((XAttribute)obj);
if (obj is XComment)
return MakeWrapper((XComment)obj);
if (obj is XProcessingInstruction)
return MakeWrapper((XProcessingInstruction)obj);
if (obj is XText)
return MakeWrapper((XText)obj);
if (obj is XElement)
return MakeWrapper((XElement)obj);
if (obj is XDocument)
return MakeWrapper((XDocument)obj);
throw new NotSupportedException(obj.GetType().FullName);
}
示例4: XObjectNotSupportedException
public XObjectNotSupportedException(XObject @object)
: base("Xml object '{0}' not supported. Only XElements and XAttributes are supported."
.ToFormat(@object.GetType().Name))
{
}