• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DomNodeType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DomNodeType的典型用法代码示例。如果您正苦于以下问题:C# DomNodeType类的具体用法?C# DomNodeType怎么用?C# DomNodeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DomNodeType类属于命名空间,在下文中一共展示了DomNodeType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestDefaultValue

        public void TestDefaultValue()
        {
            AttributeType type = new AttributeType("test", typeof(string));
            AttributeInfo test = new AttributeInfo("test", type);
            test.DefaultValue = "foo";
            Assert.AreEqual(test.DefaultValue, "foo");
            test.DefaultValue = null;
            Assert.AreEqual(test.DefaultValue, type.GetDefault());
            Assert.Throws<InvalidOperationException>(delegate { test.DefaultValue = 1; });

            AttributeType length2Type = new AttributeType("length2Type", typeof(int[]), 2);
            AttributeInfo length2Info = new AttributeInfo("length2", length2Type);
            Assert.AreEqual(length2Info.DefaultValue, length2Type.GetDefault());
            Assert.AreEqual(length2Info.DefaultValue, new int[] { default(int), default(int) });
            DomNodeType nodeType = new DomNodeType("testNodeType");
            nodeType.Define(length2Info);
            DomNode node = new DomNode(nodeType);
            Assert.AreEqual(node.GetAttribute(length2Info), length2Info.DefaultValue);
            node.SetAttribute(length2Info, new int[] { 1, 2 });
            Assert.AreEqual(node.GetAttribute(length2Info), new int[] { 1, 2 });
            node.SetAttribute(length2Info, new int[] { 1 });
            Assert.AreEqual(node.GetAttribute(length2Info), new int[] { 1 });

            AttributeType length1Type = new AttributeType("length1Type", typeof(int[]), 1);
            AttributeInfo length1Info = new AttributeInfo("length1", length1Type);
            Assert.AreEqual(length1Info.DefaultValue, length1Type.GetDefault());
            Assert.AreEqual(length1Info.DefaultValue, new int[] { default(int) });
            nodeType = new DomNodeType("testNodeType");
            nodeType.Define(length1Info);
            node = new DomNode(nodeType);
            Assert.AreEqual(node.GetAttribute(length1Info), length1Info.DefaultValue);
            node.SetAttribute(length1Info, new int[] { 1 });
            Assert.AreEqual(node.GetAttribute(length1Info), new int[] { 1 });
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:34,代码来源:TestAttributeInfo.cs


示例2: TestValidate

        public void TestValidate()
        {
            DomNodeType childType = new DomNodeType("child");
            DomNodeType parentType = new DomNodeType("parent");
            ChildInfo childInfo = new ChildInfo("child", childType, true);
            parentType.Define(childInfo);
            DomNode parent = new DomNode(parentType);
            IList<DomNode> childList = parent.GetChildList(childInfo);
            DomNode child1 = new DomNode(childType);
            DomNode child2 = new DomNode(childType);
            DomNode child3 = new DomNode(childType);

            ChildCountRule test = new ChildCountRule(1, 2);
            
            // 0 children. Not valid.
            Assert.False(test.Validate(parent, null, childInfo));

            // 1 child. Valid.
            childList.Add(child1);
            Assert.True(test.Validate(parent, null, childInfo));
            
            // 2 children. Valid.
            childList.Add(child2);
            Assert.True(test.Validate(parent, null, childInfo));

            // 3 children. Not valid.
            childList.Add(child3);
            Assert.False(test.Validate(parent, null, childInfo));

            // 0 children. Not valid.
            childList.Clear();
            Assert.False(test.Validate(parent, null, childInfo));
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:33,代码来源:TestChildCountRule.cs


示例3: 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


示例4: NativeAttributeInfo

 public NativeAttributeInfo(DomNodeType type, string name, uint typeId, uint propId)
 {
     DefiningType = type;
     Name = name;
     TypeId = typeId;
     PropertyId = propId;
 }
开发者ID:ldh9451,项目名称:XLE,代码行数:7,代码来源:NativeAttributeInfo.cs


示例5: TestCreate

 public void TestCreate()
 {
     var domType = new DomNodeType("test");
     var extension = new ExtensionInfo<TestExtensionInfo>();
     var created = extension.Create(new DomNode(domType)) as TestExtensionInfo;
     Assert.NotNull(created);
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:7,代码来源:TestExtensionInfo.cs


示例6: TestBaseType

        public void TestBaseType()
        {
            DomNodeType test = new DomNodeType("test");
            Assert.AreEqual(test.BaseType, DomNodeType.BaseOfAllTypes);
            DomNodeType baseType = new DomNodeType("base");
            test.BaseType = baseType;
            Assert.AreEqual(test.BaseType, baseType);

            #pragma warning disable 219 //Disable the unused local variable warning. We need the side-effect of creating the DomNode.
            DomNode node = new DomNode(test);
            #pragma warning restore 219
            // base type is now frozen
            Assert.Throws<InvalidOperationException>(delegate { test.BaseType = new DomNodeType("newBase"); });

            test = new DomNodeType(
                "test",
                null,
                EmptyEnumerable<AttributeInfo>.Instance,
                EmptyEnumerable<ChildInfo>.Instance,
                EmptyEnumerable<ExtensionInfo>.Instance);

            Assert.AreEqual(test.BaseType, DomNodeType.BaseOfAllTypes);
            test.BaseType = baseType;
            Assert.AreEqual(test.BaseType, baseType);

            // ReSharper disable once RedundantAssignment
            node = new DomNode(test);
            Assert.Throws<InvalidOperationException>(delegate { test.BaseType = new DomNodeType("newBase"); });
        }
开发者ID:sbambach,项目名称:ATF,代码行数:29,代码来源:TestDomNodeType.cs


示例7: TestBaseType

        public void TestBaseType()
        {
            DomNodeType test = new DomNodeType("test");
            Assert.AreEqual(test.BaseType, DomNodeType.BaseOfAllTypes);
            DomNodeType baseType = new DomNodeType("base");
            test.BaseType = baseType;
            Assert.AreEqual(test.BaseType, baseType);

            DomNode node = new DomNode(test);
            // base type is now frozen
            Assert.Throws<InvalidOperationException>(delegate { test.BaseType = new DomNodeType("newBase"); });

            test = new DomNodeType(
                "test",
                null,
                EmptyEnumerable<AttributeInfo>.Instance,
                EmptyEnumerable<ChildInfo>.Instance,
                EmptyEnumerable<ExtensionInfo>.Instance);

            Assert.AreEqual(test.BaseType, DomNodeType.BaseOfAllTypes);
            test.BaseType = baseType;
            Assert.AreEqual(test.BaseType, baseType);

            node = new DomNode(test);
            Assert.Throws<InvalidOperationException>(delegate { test.BaseType = new DomNodeType("newBase"); });
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:26,代码来源:TestDomNodeType.cs


示例8: TestConstructor

 public void TestConstructor()
 {
     DomNodeType type = new DomNodeType("child");
     ChildInfo info = new ChildInfo("test", type);
     DomNode test = new DomNode(type, info);
     Assert.AreSame(test.Type, type);
     Assert.AreSame(test.ChildInfo, info);
 }
开发者ID:cococo111111,项目名称:ATF,代码行数:8,代码来源:TestDomNode.cs


示例9: TestListConstructor

 public void TestListConstructor()
 {
     DomNodeType type = new DomNodeType("child");
     ChildInfo test = new ChildInfo("test", type, true);
     Assert.AreEqual(test.Name, "test");
     Assert.AreEqual(test.Type, type);
     Assert.True(test.IsList);
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:8,代码来源:TestChildInfo.cs


示例10: TestLineage

 public void TestLineage()
 {
     DomNodeType child = new DomNodeType("child");
     Utilities.TestSequenceEqual(child.Lineage, child, DomNodeType.BaseOfAllTypes);
     DomNodeType parent = new DomNodeType("parent");
     child.BaseType = parent;
     Utilities.TestSequenceEqual(child.Lineage, child, parent, DomNodeType.BaseOfAllTypes);
 }
开发者ID:sbambach,项目名称:ATF,代码行数:8,代码来源:TestDomNodeType.cs


示例11: NodeTypePaletteItem

 /// <summary>
 /// Constructor</summary>
 /// <param name="nodeType">DomNodeType that this object applies to</param>
 /// <param name="name">User-readable name of this DomNodeType</param>
 /// <param name="description">User-readable description of this DomNodeType</param>
 /// <param name="category">Category of DomNodeType</param>
 /// <param name="imageKey">Image resource name, e.g., "DomTreeEditorSample.Resources.form.png"</param>
 public NodeTypePaletteItem(
     DomNodeType nodeType,
     string name,
     string description,
     string category,
     object imageKey)
     : this(nodeType, name, description, category, imageKey, new DomNode(nodeType))
 {
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:16,代码来源:NodeTypePaletteItem.cs


示例12: ChildInfo

 /// <summary>
 /// Constructor</summary>
 /// <param name="name">Field name</param>
 /// <param name="type">Field type</param>
 /// <param name="isList">Whether there is 1 child, or a list of children</param>
 public ChildInfo(
     string name,
     DomNodeType type,
     bool isList)
     : base(name)
 {
     m_type = type;
     m_isList = isList;
 }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:14,代码来源:ChildInfo.cs


示例13: TestEquality

        public void TestEquality()
        {
            var attrType1 = new AttributeType("xkcd", typeof(string));
            var attrInfo1 = new AttributeInfo("xkcd", attrType1);
            var domNodeType = new DomNodeType("WebComic", DomNodeType.BaseOfAllTypes);
            var childInfo1 = new ChildInfo("xkcd", domNodeType);
            attrInfo1.DefaultValue = "Firefly";
            var desc1 = new ChildAttributePropertyDescriptor(
                "xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
            int originalHashCode = desc1.GetHashCode();

            // test if two identically created property descriptors compare as being equal
            var desc2 = new ChildAttributePropertyDescriptor(
                "xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
            Assert.AreEqual(desc1, desc2);
            Assert.AreEqual(desc1.GetHashCode(), desc2.GetHashCode());

            // test category being different; oddly, although I think they should not be considered equal,
            //  the .Net PropertyDescriptor ignores the difference in category name. So, I'm guessing that
            //  the AttributePropertyDescriptor should behave the same as PropertyDescriptor.
            var desc3 = new ChildAttributePropertyDescriptor(
                "xkcd", attrInfo1, childInfo1, "Category 2", "A commonly used word or phrase in the xkcd comic", true);
            Assert.AreEqual(desc1, desc3);
            Assert.AreEqual(desc1.GetHashCode(), desc3.GetHashCode());

            // test description being different; similarly here, the .Net PropertyDescriptor doesn't care.
            var desc4 = new ChildAttributePropertyDescriptor(
                "xkcd", attrInfo1, childInfo1, "Category 1", "slightly different description", true);
            Assert.AreEqual(desc1, desc4);
            Assert.AreEqual(desc1.GetHashCode(), desc4.GetHashCode());

            // test readOnly being different; ditto for read-only flag!
            var desc5 = new ChildAttributePropertyDescriptor(
                "xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", false);
            Assert.AreEqual(desc1, desc5);
            Assert.AreEqual(desc1.GetHashCode(), desc5.GetHashCode());

            // test that the hash code hasn't changed after using the AttributeInfo
            var attrInfo2 = new AttributeInfo("xkcd", attrType1);
            domNodeType.Define(attrInfo2);
            Assert.AreEqual(desc1.GetHashCode(), originalHashCode);

            // test that the hash code hasn't changed after creating a derived DomNodeType
            var derivedDomNodeType = new DomNodeType("ScientificWebComic", domNodeType);
            var derivedAttrInfo = new AttributeInfo("xkcd", attrType1);
            var derivedChildInfo = new ChildInfo("xkcd", derivedDomNodeType);
            derivedDomNodeType.Define(derivedAttrInfo);
            Assert.AreEqual(desc1.GetHashCode(), originalHashCode);

            // test that an AttributeInfo used in a derived DomNodeType doesn't change equality or hash code
            var desc6 = new ChildAttributePropertyDescriptor(
                "xkcd", derivedAttrInfo, derivedChildInfo, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
            Assert.AreEqual(desc1, desc6);
            Assert.AreEqual(desc1.GetHashCode(), desc6.GetHashCode());
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:55,代码来源:TestChildAttributePropertyDescriptor.cs


示例14: NodeTypePaletteItem

 /// <summary>
 /// Constructor</summary>
 /// <param name="nodeType">DomNodeType that this object applies to</param>
 /// <param name="name">User-readable name of this DomNodeType</param>
 /// <param name="description">User-readable description of this DomNodeType</param>
 /// <param name="imageName">Image resource name, e.g., "DomTreeEditorSample.Resources.form.png"</param>
 public NodeTypePaletteItem(
     DomNodeType nodeType,
     string name,
     string description,
     string imageName)
 {
     NodeType = nodeType;
     Name = name;
     Description = description;
     ImageName = imageName;
 }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:17,代码来源:NodeTypePaletteItem.cs


示例15: TestChildParent

        public void TestChildParent()
        {
            DomNodeType type = new DomNodeType("type");
            ChildInfo childInfo = new ChildInfo("child", type, true);
            type.Define(childInfo);

            DomNode child = new DomNode(type);
            DomNode parent = new DomNode(type);
            parent.GetChildList(childInfo).Add(child);
            Assert.AreSame(child.Parent, parent);
        }
开发者ID:cococo111111,项目名称:ATF,代码行数:11,代码来源:TestDomNode.cs


示例16: FindLocalAnnotation

 /// <summary>
 /// Gets the Xml node with the given local name, searching the type
 /// and all of its base types</summary>
 /// <param name="type">DomNodeType whose Tag contains an IEnumerable of XmlNodes</param>
 /// <param name="name">Node's local name</param>
 /// <returns>Xml node with the given local name, or null</returns>
 public static XmlNode FindLocalAnnotation(DomNodeType type, string name)
 {
     IEnumerable<XmlNode> annotations = type.GetTagLocal<IEnumerable<XmlNode>>();
     if (annotations != null)
     {
         foreach (XmlNode xmlNode in annotations)
         {
             if (xmlNode.LocalName == name)
                 return xmlNode;
         }
     }
     return null;
 }            
开发者ID:calciferol,项目名称:LevelEditor,代码行数:19,代码来源:Annotations.cs


示例17: TestDescendantGetRoot

        public void TestDescendantGetRoot()
        {
            DomNodeType type = new DomNodeType("type");
            ChildInfo childInfo = new ChildInfo("child", type, true);
            type.Define(childInfo);

            DomNode child = new DomNode(type);
            DomNode parent = new DomNode(type);
            DomNode grandparent = new DomNode(type);
            parent.GetChildList(childInfo).Add(child);
            grandparent.GetChildList(childInfo).Add(parent);
            Assert.AreSame(child.GetRoot(), grandparent);
        }
开发者ID:cococo111111,项目名称:ATF,代码行数:13,代码来源:TestDomNode.cs


示例18: TestValidation

        public void TestValidation()
        {
            DomNodeType type = new DomNodeType("child");
            ChildInfo test = new ChildInfo("test", type);
            CollectionAssert.IsEmpty(test.Rules);

            var rule = new SimpleChildRule();
            test.AddRule(rule);

            Utilities.TestSequenceEqual(test.Rules, rule);

            Assert.True(test.Validate(null, null));
            Assert.True(rule.Validated);
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:14,代码来源:TestChildInfo.cs


示例19: TestGetAdapter

        public void TestGetAdapter()
        {
            DomNodeType nodeType = new DomNodeType(
                "child",
                null,
                EmptyEnumerable<AttributeInfo>.Instance,
                EmptyEnumerable<ChildInfo>.Instance,
                EmptyEnumerable<ExtensionInfo>.Instance);

            nodeType.SetTag<TestTypeAdapterCreator>(this); // add this as metadata to the type

            TypeAdapterCreator<TestTypeAdapterCreator> test = new TypeAdapterCreator<TestTypeAdapterCreator>();
            Assert.AreEqual(test.GetAdapter(new DomNode(nodeType), typeof(TestTypeAdapterCreator)), this);
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:14,代码来源:TestTypeAdapterCreator.cs


示例20: TestGetPath

        public void TestGetPath()
        {
            DomNodeType type = new DomNodeType("type");
            ChildInfo childInfo = new ChildInfo("child", type, true);
            type.Define(childInfo);

            DomNode child = new DomNode(type);
            DomNode parent = new DomNode(type);
            DomNode grandparent = new DomNode(type);
            parent.GetChildList(childInfo).Add(child);
            grandparent.GetChildList(childInfo).Add(parent);

            Utilities.TestSequenceEqual(child.GetPath(), grandparent, parent, child);
            Utilities.TestSequenceEqual(parent.GetPath(), grandparent, parent);
            Utilities.TestSequenceEqual(grandparent.GetPath(), grandparent);
        }
开发者ID:cococo111111,项目名称:ATF,代码行数:16,代码来源:TestDomNode.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DomRegion类代码示例发布时间:2022-05-24
下一篇:
C# DomNode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap