当前位置: 首页>>代码示例>>C#>>正文


C# DomNode.GetExtension方法代码示例

本文整理汇总了C#中DomNode.GetExtension方法的典型用法代码示例。如果您正苦于以下问题:C# DomNode.GetExtension方法的具体用法?C# DomNode.GetExtension怎么用?C# DomNode.GetExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DomNode的用法示例。


在下文中一共展示了DomNode.GetExtension方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestDuplicateNames

        // Tests http://tracker.ship.scea.com/jira/browse/WWSATF-1370
        // Test adding two types of extensions that have the same Name but different FullName.
        public void TestDuplicateNames()
        {
            var domType = new DomNodeType("domType");
            var extension = new ExtensionInfo<TestExtensionInfo>();
            domType.Define(extension);

            var domDerivedType = new DomNodeType("domDerivedType", domType);
            var anotherExtension = new ExtensionInfo<AnotherName.TestExtensionInfo>();
            domDerivedType.Define(anotherExtension);

            var domNode = new DomNode(domDerivedType);
            domNode.InitializeExtensions();
            Assert.IsTrue(domNode.GetExtension(extension).GetType() == typeof(TestExtensionInfo));
            Assert.IsTrue(domNode.GetExtension(anotherExtension).GetType() == typeof(AnotherName.TestExtensionInfo));

            ExtensionInfo getInfo = domType.GetExtensionInfo("UnitTests.Atf.Dom.TestExtensionInfo");
            Assert.IsNotNull(getInfo);
            Assert.AreEqual(getInfo, extension);

            getInfo = domDerivedType.GetExtensionInfo("UnitTests.Atf.Dom.TestExtensionInfo");
            Assert.IsNotNull(getInfo);
            Assert.AreEqual(getInfo, extension);
            
            ExtensionInfo anotherGetInfo = domDerivedType.GetExtensionInfo("UnitTests.Atf.Dom.AnotherName.TestExtensionInfo");
            Assert.IsNotNull(anotherGetInfo);
            Assert.AreEqual(anotherGetInfo, anotherExtension);
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:29,代码来源:TestExtensionInfo.cs

示例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"));
        }
开发者ID:sbambach,项目名称:ATF,代码行数:36,代码来源:TestDomNodeType.cs

示例3: TestExtensionsAfterConstructing

        public void TestExtensionsAfterConstructing()
        {
            DomNodeType type = new DomNodeType("test");
            ExtensionInfo info1 = new ExtensionInfo<TestDomNode>();
            type.Define(info1);
            ExtensionInfo info2 = new ExtensionInfo<int>();
            type.Define(info2);

            DomNode test = new DomNode(type);
            Assert.True(test.GetExtension(info1) as TestDomNode != null);
            Assert.True(test.GetExtension(info2) is int);
        }
开发者ID:cococo111111,项目名称:ATF,代码行数:12,代码来源:TestDomNode.cs


注:本文中的DomNode.GetExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。