本文整理汇总了C#中DomNode.GetDecorators方法的典型用法代码示例。如果您正苦于以下问题:C# DomNode.GetDecorators方法的具体用法?C# DomNode.GetDecorators怎么用?C# DomNode.GetDecorators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomNode
的用法示例。
在下文中一共展示了DomNode.GetDecorators方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetDecoratorsInherited
public void TestGetDecoratorsInherited()
{
DomNodeType baseType = new DomNodeType("baseType");
baseType.Define(new ExtensionInfo<DerivedAdapter>()); // derived adapter on base type!
DomNodeType derivedType = new DomNodeType("derivedType");
derivedType.BaseType = baseType;
derivedType.Define(new ExtensionInfo<SimpleAdapter>());
DomNode node = new DomNode(derivedType);
object simple = node.GetAdapter(typeof(SimpleAdapter));
object derived = node.GetAdapter(typeof(DerivedAdapter));
// test that they're returned in order of inheritance
Utilities.TestSequenceEqual(node.GetDecorators(typeof(SimpleAdapter)), simple, derived);
}
示例2: TestDuplicateExtensionInfo
public void TestDuplicateExtensionInfo()
{
var ext1 = new ExtensionInfo<TestAdapter1>("foo");
var ext2 = new ExtensionInfo<TestAdapter2>("foo");
var domType = new DomNodeType(
"test",
null,
EmptyEnumerable<AttributeInfo>.Instance,
EmptyEnumerable<ChildInfo>.Instance,
new ExtensionInfo[] { ext1, ext2 });
var domNode = new DomNode(domType);
object resultExt1 = domNode.GetExtension(ext1);
object resultExt2 = domNode.GetExtension(ext2);
Assert.IsTrue(resultExt1 is TestAdapter1);
Assert.IsTrue(resultExt2 is TestAdapter2);
object[] decorators = domNode.GetDecorators(typeof(object)).ToArray();
Assert.IsTrue(
decorators.Length == 2 &&
decorators[0] == resultExt1 &&
decorators[1] == resultExt2);
DomNodeAdapter[] extensions = domNode.AsAll<DomNodeAdapter>().ToArray();
Assert.IsTrue(
extensions.Length == 2 &&
extensions[0] == resultExt1 &&
extensions[1] == resultExt2);
// Searching by name is a problem, though. The search is ambiguous.
// See tracker item for discussion: http://tracker.ship.scea.com/jira/browse/WWSATF-522
Assert.Throws<InvalidOperationException>(() => domType.GetExtensionInfo("foo"));
}
示例3: TestGetDecorators
public void TestGetDecorators()
{
DomNodeType type = new DomNodeType("type");
type.Define(new ExtensionInfo<SimpleAdapter>());
type.Define(new ExtensionInfo<DerivedAdapter>());
DomNode node = new DomNode(type);
object simple = node.GetAdapter(typeof(SimpleAdapter));
object derived = node.GetAdapter(typeof(DerivedAdapter));
// test that they're returned in order of definition on node
Utilities.TestSequenceEqual(node.GetDecorators(typeof(SimpleAdapter)), simple, derived);
}