Beispiel #1
0
 /// <summary>
 /// Returns true iff the specified attribute is translation, rotation or scale</summary>
 /// <param name="attributeInfo"></param>
 /// <returns>True iff the specified attribute is translation, rotation or scale</returns>
 private bool IsTransformAttribute(AttributeInfo attributeInfo)
 {
     // Always use the Equivalent method when comparing two AttributeInfos
     // because using simple equality (==) doesn't respect inheritance
     // i.e. (Schema.baseType.someAttribute == Schema.derivedType.someAttribute) returns false
     // whereas (Schema.baseType.someAttribue.Equivalent(Schema.derivedType.someAttribute)) returns true
     return (attributeInfo.Equivalent(Schema.transformObjectType.translateAttribute)
             || attributeInfo.Equivalent(Schema.transformObjectType.rotateAttribute)
             || attributeInfo.Equivalent(Schema.transformObjectType.scaleAttribute)
             || attributeInfo.Equivalent(Schema.transformObjectType.pivotAttribute));
 }
Beispiel #2
0
        public void TestOverriddenAttributeInfo()
        {
            AttributeInfo info = new AttributeInfo("foo", new AttributeType("foo", typeof(string)));
            DomNodeType test = new DomNodeType(
                "test",
                null,
                new AttributeInfo[] { info },
                EmptyEnumerable<ChildInfo>.Instance,
                EmptyEnumerable<ExtensionInfo>.Instance);

            AttributeInfo overridden = new AttributeInfo("foo", new AttributeType("foo", typeof(string)));
            DomNodeType child = new DomNodeType("child", test,
                new AttributeInfo[] { overridden },
                EmptyEnumerable<ChildInfo>.Instance,
                EmptyEnumerable<ExtensionInfo>.Instance);

            Assert.AreSame(child.GetAttributeInfo("foo"), overridden);
            Assert.AreEqual(overridden.OwningType, child);
            Assert.AreEqual(overridden.DefiningType, test);

            Assert.True(info.Equivalent(overridden));
            Assert.True(overridden.Equivalent(info));

            Assert.True(test.IsValid(overridden));
            Assert.True(child.IsValid(info));
        }
Beispiel #3
0
        public void TestInheritedAttributeInfo()
        {
            AttributeInfo info = new AttributeInfo("foo", new AttributeType("foo", typeof(string)));
            DomNodeType test = new DomNodeType(
                "test",
                null,
                new AttributeInfo[] { info },
                EmptyEnumerable<ChildInfo>.Instance,
                EmptyEnumerable<ExtensionInfo>.Instance);

            DomNodeType child = new DomNodeType("child");
            child.BaseType = test;

            AttributeInfo inherited = child.GetAttributeInfo("foo");
            Assert.AreEqual(inherited.OwningType, test);
            Assert.AreEqual(inherited.DefiningType, test);

            Assert.True(inherited.Equivalent(info));
            Assert.True(info.Equivalent(inherited));
        }