Ejemplo n.º 1
0
        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"); });
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        // 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);
        }
Ejemplo n.º 4
0
        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 });
        }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
        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"); });
        }
Ejemplo n.º 7
0
 public NativeAttributeInfo(DomNodeType type, string name, uint typeId, uint propId)
 {
     DefiningType = type;
     Name = name;
     TypeId = typeId;
     PropertyId = propId;
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
 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);
 }
Ejemplo n.º 11
0
 /// <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;
 }
Ejemplo n.º 12
0
 /// <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))
 {
 }
        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());
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
 /// <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;
 }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
 /// <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;
 }            
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
 /// <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>
 /// <param name="protoType">Prototype DomNode</param>
 public NodeTypePaletteItem(
     DomNodeType nodeType,
     string name,
     string description,
     string category,
     object imageKey,
     DomNode protoType)
 {
     NodeType = nodeType;
     Name = name;
     Category = category;
     Description = description;
     ImageKey = imageKey;
     Prototype = protoType;
 }
Ejemplo n.º 21
0
 /// <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>
 /// <param name="category">Category in which the type is displayed in the palette control</param>
 /// <param name="menuText">Text for the context-menu command to add a new instance of this type</param>
 public NodeTypePaletteItem(
     DomNodeType nodeType,
     string name,
     string description,
     string imageName,
     string category,
     string menuText)
 {
     NodeType = nodeType;
     Name = name;
     Description = description;
     ImageName = imageName;
     Category = category;
     MenuText = menuText;
 }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        public bool TryGetVariable(string name, DomNodeType nodeType, out ISledLuaVarBaseType luaVar)
        {
            luaVar = null;

            if (string.IsNullOrEmpty(name))
                return false;

            if (nodeType == null)
                return false;

            if (m_dictVarServices.Count <= 0)
                return false;

            ISledLuaVariableService variableService;
            return
                m_dictVarServices.TryGetValue(nodeType, out variableService) &&
                variableService.TryGetVariable(name, out luaVar);
        }
Ejemplo n.º 24
0
        public TestValidator()
        {
            // define a tree of validation contexts
            m_childType = new DomNodeType("test");
            m_stringAttrInfo = GetStringAttribute("string");
            m_childType.Define(m_stringAttrInfo);
            m_refAttrInfo = GetRefAttribute("ref");
            m_childType.Define(m_refAttrInfo);
            m_childInfo = new ChildInfo("child", m_childType);
            m_childType.Define(m_childInfo);
            m_childType.Define(new ExtensionInfo<ValidationContext>());

            // define a distinct root type with the validator
            m_rootType = new DomNodeType("root");
            m_rootType.BaseType = m_childType;
            m_rootType.Define(new ExtensionInfo<Validator>());

            IEnumerable<AttributeInfo> attributes = m_rootType.Attributes; // freezes the types
        }
Ejemplo n.º 25
0
        protected DomNodeType RootType;//derives from ChildType

        public TestValidator()
        {
            // define a tree of validation contexts
            ChildType = new DomNodeType("test");
            StringAttrInfo = GetStringAttribute("string");
            ChildType.Define(StringAttrInfo);
            RefAttrInfo = GetRefAttribute("ref");
            ChildType.Define(RefAttrInfo);
            ChildInfo = new ChildInfo("child", ChildType);
            ChildType.Define(ChildInfo);
            ChildType.Define(new ExtensionInfo<ValidationContext>());

            // define a distinct root type with the validator
            RootType = new DomNodeType("root");
            RootType.BaseType = ChildType;
            RootType.Define(new ExtensionInfo<Validator>());
            AttributeInfo overriddenInfo = GetStringAttribute("string");
            RootType.Define(overriddenInfo);

            IEnumerable<AttributeInfo> attributes = RootType.Attributes; // freezes the types
        }
        /// <summary>
        /// Prepare metadata for the module type, to be used by the palette and circuit drawing engine
        /// </summary>
        /// <param name="name"> Schema full name of the DomNodeType for the module type</param>
        /// <param name="displayName">Display name for the module type</param>
        /// <param name="description"></param>
        /// <param name="imageName">Image name </param>
        /// <param name="inputs">Define input pins for the module type</param>
        /// <param name="outputs">Define output pins for the module type</param>
        /// <param name="loader">XML schema loader </param>
        /// <param name="domNodeType">optional DomNode type for the module type</param>
        /// <returns>DomNodeType that was created (or the domNodeType parameter, if it wasn't null)</returns>
        protected DomNodeType DefineModuleType(

            XmlQualifiedName name,
            string displayName,
            string description,
            string category,
            string imageName,
            DomNodeTypeCollection typeCollection,
            DomNodeType domNodeType = null)
        {
            if (domNodeType == null)
            {
                // create the type
                domNodeType = new DomNodeType(
                    name.ToString(),
                    moduleType.Type,
                    EmptyArray <AttributeInfo> .Instance,
                    EmptyArray <ChildInfo> .Instance,
                    new ExtensionInfo[] { new ExtensionInfo <ScriptNodeElementType>() });
            }

            // add it to the schema-defined types
            typeCollection.AddNodeType(name.ToString(), domNodeType);

            // add the type to the palette
            if (m_paletteService != null)
            {
                m_paletteService.AddItem(
                    new NodeTypePaletteItem(
                        domNodeType,
                        displayName,
                        description,
                        imageName),
                    string.IsNullOrEmpty(category) ? PaletteCategory : category,
                    this);
            }

            return(domNodeType);
        }
Ejemplo n.º 27
0
        public void TestInheritedExtensionInfo()
        {
            ExtensionInfo info = new ExtensionInfo <TestDomNodeType>("foo");
            DomNodeType   test = new DomNodeType(
                "test",
                null,
                EmptyEnumerable <AttributeInfo> .Instance,
                EmptyEnumerable <ChildInfo> .Instance,
                new ExtensionInfo[] { info });

            DomNodeType child = new DomNodeType("child");

            child.BaseType = test;

            ExtensionInfo inherited = child.GetExtensionInfo("foo");

            Assert.AreEqual(inherited.OwningType, test);
            Assert.AreEqual(inherited.DefiningType, test);

            Assert.True(inherited.Equivalent(info));
            Assert.True(info.Equivalent(inherited));
        }
Ejemplo n.º 28
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));
        }
Ejemplo n.º 29
0
        protected DomNodeType RootType;         //derives from ChildType

        public TestValidator()
        {
            // define a tree of validation contexts
            ChildType      = new DomNodeType("test");
            StringAttrInfo = GetStringAttribute("string");
            ChildType.Define(StringAttrInfo);
            RefAttrInfo = GetRefAttribute("ref");
            ChildType.Define(RefAttrInfo);
            ChildInfo = new ChildInfo("child", ChildType);
            ChildType.Define(ChildInfo);
            ChildType.Define(new ExtensionInfo <ValidationContext>());

            // define a distinct root type with the validator
            RootType          = new DomNodeType("root");
            RootType.BaseType = ChildType;
            RootType.Define(new ExtensionInfo <Validator>());
            AttributeInfo overriddenInfo = GetStringAttribute("string");

            RootType.Define(overriddenInfo);

            IEnumerable <AttributeInfo> attributes = RootType.Attributes; // freezes the types
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Gets all the annotation with given name for 
        /// the given type all the way to the root.
        /// <remarks> If name is null or empty then get all the annotations.</remarks>
        /// </summary>                
        public static IEnumerable<XmlElement> GetAllAnnotation(DomNodeType type, string name)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            var list = new List<XmlElement>();
            DomNodeType nodetype = type;
            while(nodetype != null)
            {
                IEnumerable<XmlNode> annotations = nodetype.GetTagLocal<IEnumerable<XmlNode>>();
                if (annotations != null)
                {
                    foreach (var annot in annotations)
                    {
                        if (string.IsNullOrWhiteSpace(name) || annot.LocalName == name)
                            list.Add((XmlElement)annot);
                    }
                }
                nodetype = nodetype.BaseType;
            }
            return list;
        }
Ejemplo n.º 31
0
        public TestDataValidator()
        {
            m_childType = new DomNodeType("child");
            m_parentType = new DomNodeType("parent");
            m_parentType.Define(new ExtensionInfo<ValidationContext>());
            m_parentType.Define(new ExtensionInfo<DataValidator>());

            m_childCountRule = new ChildCountRule(2, 3);
            m_childInfo = new ChildInfo("child", m_childType, true);
            m_parentType.Define(m_childInfo);
            m_childInfo.AddRule(m_childCountRule);

            m_parent = new DomNode(m_parentType);
            m_parent.InitializeExtensions();

            m_validationContext = m_parent.As<ValidationContext>();

            m_child1 = new DomNode(m_childType);
            m_child2 = new DomNode(m_childType);
            m_child3 = new DomNode(m_childType);
            m_child4 = new DomNode(m_childType);
        }
        public TestDataValidator()
        {
            m_childType  = new DomNodeType("child");
            m_parentType = new DomNodeType("parent");
            m_parentType.Define(new ExtensionInfo <ValidationContext>());
            m_parentType.Define(new ExtensionInfo <DataValidator>());

            m_childCountRule = new ChildCountRule(2, 3);
            m_childInfo      = new ChildInfo("child", m_childType, true);
            m_parentType.Define(m_childInfo);
            m_childInfo.AddRule(m_childCountRule);

            m_parent = new DomNode(m_parentType);
            m_parent.InitializeExtensions();

            m_validationContext = m_parent.As <ValidationContext>();

            m_child1 = new DomNode(m_childType);
            m_child2 = new DomNode(m_childType);
            m_child3 = new DomNode(m_childType);
            m_child4 = new DomNode(m_childType);
        }
Ejemplo n.º 33
0
 /// <summary>
 /// Find all the DomNodes of the type that is equal or derived
 /// from the given type.
 /// if exact is true then only find DomNode that have exact type.
 /// </summary>
 /// <param name="type">DomNodeType</param>
 /// <param name="exact">if true then only consider exact match,
 /// otherwise match any type that is equal or derived from the given type</param>
 /// <returns></returns>
 public static IEnumerable <DomNode> FindAll(DomNodeType type, bool exact = false)
 {
     if (type != null)
     {
         IGameDocumentRegistry gameDocumentRegistry = Globals.MEFContainer.GetExportedValue <IGameDocumentRegistry>();
         if (gameDocumentRegistry != null)
         {
             foreach (IGameDocument doc in gameDocumentRegistry.Documents)
             {
                 DomNode folderNode = doc.RootGameObjectFolder.Cast <DomNode>();
                 foreach (DomNode childNode in folderNode.Subtree)
                 {
                     if ((exact && childNode.Type == type) ||
                         (!exact && type.IsAssignableFrom(childNode.Type)))
                     {
                         yield return(childNode);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 34
0
        public void TestChildListRemove()
        {
            DomNodeType type      = new DomNodeType("type");
            ChildInfo   childInfo = new ChildInfo("child", type, true);

            type.Define(childInfo);
            DomNode         parent = new DomNode(type);
            IList <DomNode> list   = parent.GetChildList(childInfo);
            DomNode         child1 = new DomNode(type);

            Assert.False(list.Remove(child1));
            list.Add(child1);
            DomNode child2 = new DomNode(type);

            list.Add(child2);

            Assert.True(list.Remove(child1));
            Utilities.TestSequenceEqual(list, child2);

            Assert.True(list.Remove(child2));
            CollectionAssert.IsEmpty(list);
        }
Ejemplo n.º 35
0
        private void DefineCircuitType(
            DomNodeType type,
            string elementTypeName,
            string imageName,
            ICircuitPin[] inputs,
            ICircuitPin[] outputs)
        {
            // create an element type and add it to the type metadata
            // For now, let all circuit elements be used as 'connectors' which means
            //  that their pins will be used to create the pins on a master instance.
            bool isConnector = true; //(inputs.Length + outputs.Length) == 1;
            var  image       = string.IsNullOrEmpty(imageName) ? null : ResourceUtil.GetImage32(imageName);

            type.SetTag <ICircuitElementType>(
                new ElementType(
                    elementTypeName,
                    isConnector,
                    new Size(),
                    image,
                    inputs,
                    outputs));
        }
Ejemplo n.º 36
0
        public void TestRemoveFromParent()
        {
            DomNodeType type      = new DomNodeType("type");
            ChildInfo   childInfo = new ChildInfo("child", type);

            type.Define(childInfo);
            DomNode parent = new DomNode(type);
            DomNode child  = new DomNode(type);

            parent.SetChild(childInfo, child);
            child.RemoveFromParent();
            Assert.Null(parent.GetChild(childInfo));
            Assert.Null(child.Parent);

            // Make sure the removed child has a null Parent. http://tracker.ship.scea.com/jira/browse/WWSATF-1336
            parent.SetChild(childInfo, child);
            DomNode newChild = new DomNode(type);

            parent.SetChild(childInfo, newChild);
            Assert.Null(child.Parent);
            Assert.True(newChild.Parent == parent);
        }
Ejemplo n.º 37
0
        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 });
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Prepare metadata for the module type, to be used by the palette and circuit drawing engine</summary>
        /// <param name="name"> Schema full name of the DomNodeType for the module type</param>
        /// <param name="displayName">Display name for the module type</param>
        /// <param name="description"></param>
        /// <param name="imageName">Image name </param>
        /// <param name="inputs">Define input pins for the module type</param>
        /// <param name="outputs">Define output pins for the module type</param>
        /// <param name="loader">XML schema loader </param>
        /// <param name="domNodeType">optional DomNode type for the module type</param>
        /// <returns>DomNodeType that was created (or the domNodeType parameter, if it wasn't null)</returns>
        protected DomNodeType DefineModuleType(
            XmlQualifiedName name,
            string displayName,
            string description,
            string imageName,
            ElementType.Pin[] inputs,
            ElementType.Pin[] outputs,
            SchemaLoader loader,
            DomNodeType domNodeType = null)
        {
            if (domNodeType == null)
            {
                // create the type
                domNodeType = new DomNodeType(
                    name.ToString(),
                    Schema.moduleType.Type,
                    EmptyArray <AttributeInfo> .Instance,
                    EmptyArray <ChildInfo> .Instance,
                    EmptyArray <ExtensionInfo> .Instance);
            }

            DefineCircuitType(domNodeType, displayName, imageName, inputs, outputs);

            // add it to the schema-defined types
            loader.AddNodeType(name.ToString(), domNodeType);

            // add the type to the palette
            m_paletteService.AddItem(
                new NodeTypePaletteItem(
                    domNodeType,
                    displayName,
                    description,
                    imageName),
                PaletteCategory,
                this);

            return(domNodeType);
        }
Ejemplo n.º 39
0
        public void TestChildListIndexer()
        {
            DomNodeType type      = new DomNodeType("type");
            ChildInfo   childInfo = new ChildInfo("child", type, true);

            type.Define(childInfo);
            DomNode         parent = new DomNode(type);
            IList <DomNode> list   = parent.GetChildList(childInfo);
            DomNode         child1 = new DomNode(type);

            Assert.Throws <IndexOutOfRangeException>(delegate { list[0] = child1; });
            list.Add(child1);
            Assert.AreSame(list[0], child1);
            DomNode child2 = new DomNode(type);

            list.Add(child2);
            Assert.AreSame(list[1], child2);

            DomNode child3 = new DomNode(type);

            list[0] = child3;
            Utilities.TestSequenceEqual(list, child3, child2); // child1 gets removed by set
        }
Ejemplo n.º 40
0
        internal override void AssertCanAppend(DomNode node, DomNode willReplace)
        {
            DomNodeType nodeType = node.NodeType;

            switch (nodeType)
            {
            case DomNodeType.Attribute:
            case DomNodeType.Document:
            case DomNodeType.DocumentFragment:
            case DomNodeType.EntityReference:
            case DomNodeType.CDataSection:
                throw DomFailure.CannotAppendChildNodeWithType(nodeType);

            case DomNodeType.Text:
                if (string.IsNullOrWhiteSpace(node.TextContent))
                {
                    return;
                }
                throw DomFailure.CannotAppendNonWSText();

            case DomNodeType.Element:
                var root = DocumentElement;
                if (root == null || root == node || root == willReplace)
                {
                    return;
                }
                throw DomFailure.CannotHaveMultipleRoots();

            case DomNodeType.Unspecified:
            case DomNodeType.Entity:
            case DomNodeType.ProcessingInstruction:
            case DomNodeType.Comment:
            case DomNodeType.DocumentType:
            case DomNodeType.Notation:
                return;
            }
        }
Ejemplo n.º 41
0
        void IInitializable.Initialize()
        {
            // parse resource metadata annotation.

            HashSet <string> metafileExts = new HashSet <string>();

            char[] sep = { ';' };
            foreach (ChildInfo chInfo in m_schemaLoader.GetRootElements())
            {
                DomNodeType           domtype     = chInfo.Type;
                IEnumerable <XmlNode> annotations = domtype.GetTag <IEnumerable <XmlNode> >();
                if (annotations == null)
                {
                    continue;
                }

                foreach (XmlElement annot in annotations)
                {
                    if (annot.LocalName != "ResourceMetadata")
                    {
                        continue;
                    }

                    string metaExt = annot.GetAttribute("metadataFileExt").ToLower();
                    metafileExts.Add(metaExt);
                    string[] resExts = annot.GetAttribute("resourceFileExts").ToLower().Split(sep, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string ext in resExts)
                    {
                        ResourceMetadataInfo metadataInfo
                            = new ResourceMetadataInfo(chInfo, metaExt);
                        m_extMap.Add(ext, metadataInfo);
                    }
                }
            }
            m_metadataFileExts = new string[metafileExts.Count];
            metafileExts.CopyTo(m_metadataFileExts);
        }
Ejemplo n.º 42
0
        public void TestAreEqual()
        {
            TestAreEqual <SByte>(0, 1);
            TestAreEqual <Byte>(0, 1);
            TestAreEqual <Int16>(0, 1);
            TestAreEqual <UInt16>(0, 1);
            TestAreEqual <Int32>(0, 1);
            TestAreEqual <UInt32>(0, 1);
            TestAreEqual <Int64>(0, 1);
            TestAreEqual <UInt64>(0, 1);
            TestAreEqual <Single>(0, 1);
            TestAreEqual <Double>(0, 1);
            TestAreEqual <Decimal>(0, 1);
            TestAreEqual <Boolean>(true, false);
            TestAreEqual <String>("foo", "bar");

            TestAreEqualScalar <DateTime>(DateTime.Now, new DateTime());

            TestAreEqualScalar <Uri>(new Uri("foo", UriKind.Relative), new Uri("bar", UriKind.Relative));

            DomNodeType nodeType = new DomNodeType("foo");

            TestAreEqualScalar <DomNode>(new DomNode(nodeType), new DomNode(nodeType));
        }
Ejemplo n.º 43
0
        private void SelectAllInstances()
        {
            DomNodeType domNodeType = SelectedNodeType;

            if (domNodeType == null)
            {
                return;
            }

            ISelectionContext selectionContext = SelectionContext;

            if (selectionContext == null)
            {
                return;
            }

            DomNode rootNode = GetRootNode(selectionContext);

            if (rootNode == null)
            {
                return;
            }


            selectionContext.Clear();
            List <Path <object> > newSelection = new List <Path <object> >();

            foreach (DomNode domNode in GetNodesOfType(rootNode, domNodeType))
            {
                newSelection.Add(Util.AdaptDomPath(domNode));
            }
            if (newSelection.Count > 0)
            {
                selectionContext.SetRange(newSelection);
            }
        }
Ejemplo n.º 44
0
        public void TestClone()
        {
            TestClone <SByte>(1);
            TestClone <Byte>(1);
            TestClone <Int16>(1);
            TestClone <UInt16>(1);
            TestClone <Int32>(1);
            TestClone <UInt32>(1);
            TestClone <Int64>(1);
            TestClone <UInt64>(1);
            TestClone <Single>(1);
            TestClone <Double>(1);
            TestClone <Decimal>(1);
            TestClone <Boolean>(true);
            TestClone <String>("foo");

            TestCloneScalar <DateTime>(DateTime.Now);

            TestCloneScalar <Uri>(new Uri("foo", UriKind.Relative));

            DomNodeType nodeType = new DomNodeType("foo");

            TestCloneScalar <DomNode>(new DomNode(nodeType));
        }
Ejemplo n.º 45
0
        /// <summary>
        /// Converts the palette item into an object that can be inserted into an
        /// IInstancingContext</summary>
        /// <param name="item">Item to convert</param>
        /// <returns>Object that can be inserted into an IInstancingContext</returns>
        object IPaletteClient.Convert(object item)
        {
            DomNodeType nodeType = (DomNodeType)item;
            DomNode     node     = new DomNode(nodeType);

            NodeTypePaletteItem paletteItem = nodeType.GetTag <NodeTypePaletteItem>();

            if (paletteItem != null)
            {
                if (nodeType.IdAttribute != null)
                {
                    node.SetAttribute(nodeType.IdAttribute, paletteItem.Name); // unique id, for referencing
                }
                if (nodeType == DomTypes.eventType.Type)
                {
                    node.SetAttribute(DomTypes.eventType.nameAttribute, paletteItem.Name);
                }
                else if (DomTypes.resourceType.Type.IsAssignableFrom(nodeType))
                {
                    node.SetAttribute(DomTypes.resourceType.nameAttribute, paletteItem.Name);
                }
            }
            return(node);
        }
Ejemplo n.º 46
0
        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"));
        }
Ejemplo n.º 47
0
        public void TestCopy_MultipleNodes()
        {
            DomNodeType type     = new DomNodeType("type");
            ChildInfo   info     = new ChildInfo("child", type);
            ChildInfo   infoList = new ChildInfo("childList", type, true);

            type.Define(info);
            type.Define(infoList);
            ChildInfo rootInfo = new ChildInfo("root", type, true);
            DomNode   test     = new DomNode(type, rootInfo);
            DomNode   child1   = new DomNode(type);

            test.SetChild(info, child1);
            DomNode         child2 = new DomNode(type);
            DomNode         child3 = new DomNode(type);
            IList <DomNode> list   = test.GetChildList(infoList);

            list.Add(child2);
            list.Add(child3);

            DomNode[] result = DomNode.Copy(new DomNode[] { test });
            Assert.AreEqual(result.Length, 1);
            Assert.True(Equals(result[0], test));
        }
Ejemplo n.º 48
0
 static groupSocketType()
 {
     Type             = new DomNodeType("groupSocketType", socketType.Type);
     nameAttribute    = socketType.nameAttribute;
     typeAttribute    = socketType.typeAttribute;
     moduleAttribute  = Type.DefineNewAttributeInfo("module", AttributeType.DomNodeRefType);
     pinAttribute     = Type.DefineNewAttributeInfo("pin", AttributeType.NameStringType);
     visibleAttribute = Type.DefineNewAttributeInfo("visible", AttributeType.BooleanType, defaultValue: true);
     indexAttribute   = Type.DefineNewAttributeInfo("index", AttributeType.IntType);
     pinNameAttribute = Type.DefineNewAttributeInfo("pinName", AttributeType.NameStringType);
     pinnedAttribute  = Type.DefineNewAttributeInfo("pinned", AttributeType.BooleanType, defaultValue: true);
     pinYAttribute    = Type.DefineNewAttributeInfo("pinY", AttributeType.IntType);
     Type.SetTag(new System.ComponentModel.PropertyDescriptorCollection(new PropertyDescriptor[] {
         new AttributePropertyDescriptor("name".Localize(), nameAttribute, null, "name".Localize(), false, null, null),
         new AttributePropertyDescriptor("type".Localize(), typeAttribute, null, "type".Localize(), false, null, null),
         new AttributePropertyDescriptor("module".Localize(), moduleAttribute, null, "module".Localize(), false, null, null),
         new AttributePropertyDescriptor("pin".Localize(), pinAttribute, null, "pin".Localize(), false, null, null),
         new AttributePropertyDescriptor("visible".Localize(), visibleAttribute, null, "visible".Localize(), false, null, null),
         new AttributePropertyDescriptor("index".Localize(), indexAttribute, null, "index".Localize(), false, null, null),
         new AttributePropertyDescriptor("pinName".Localize(), pinNameAttribute, null, "pinName".Localize(), false, null, null),
         new AttributePropertyDescriptor("pinned".Localize(), pinnedAttribute, null, "pinned".Localize(), false, null, null),
         new AttributePropertyDescriptor("pinY".Localize(), pinYAttribute, null, "pinY".Localize(), false, null, null),
     }));
 }
Ejemplo n.º 49
0
        public void TestGetAttribute()
        {
            DomNodeType   type = new DomNodeType("child");
            AttributeInfo info = GetIntAttribute("int");

            type.Define(info);
            DomNode test = new DomNode(type);

            Assert.True(test.IsAttributeDefault(info));
            Assert.Null(test.GetLocalAttribute(info));

            test.SetAttribute(info, 2);
            Assert.AreEqual(test.GetAttribute(info), 2);
            Assert.AreEqual(test.GetLocalAttribute(info), 2);
            Assert.False(test.IsAttributeDefault(info));

            test.SetAttribute(info, null);
            Assert.True(test.IsAttributeDefault(info));
            Assert.Null(test.GetLocalAttribute(info));

            test.SetAttribute(info, 0);
            Assert.AreEqual(test.GetAttribute(info), 0);
            Assert.True(test.IsAttributeDefault(info));
        }
Ejemplo n.º 50
0
 private static string GetClassName(DomNodeType nodeType, Dictionary<string, string> domNodeTypeToClassName)
 {
     return domNodeTypeToClassName[nodeType.Name];
 }
Ejemplo n.º 51
0
        private static void GenerateInitializers(DomNodeType nodeType, string typeName, StringBuilder sb)
        {
            string ns = "";
            string name = nodeType.Name;
            int separator = name.LastIndexOf(':'); // find colon separating ns from name
            if (separator >= 0)
            {
                ns = name.Substring(0, separator);
                name = name.Substring(separator + 1);
            }

            WriteLine(sb, "            {0}.Type = getNodeType(\"{1}\", \"{2}\");", typeName, ns, name);

            foreach (AttributeInfo attributeInfo in nodeType.Attributes)
            {
                string attrInfoName = CreateIdentifier(attributeInfo.Name + "Attribute");
                WriteLine(sb, "            {1}.{0} = {1}.Type.GetAttributeInfo(\"{2}\");", attrInfoName, typeName, attributeInfo.Name);
            }
            foreach (ChildInfo childInfo in nodeType.Children)
            {
                string childInfoName = CreateIdentifier(childInfo.Name + "Child");
                WriteLine(sb, "            {1}.{0} = {1}.Type.GetChildInfo(\"{2}\");", childInfoName, typeName, childInfo.Name);
            }
        }
Ejemplo n.º 52
0
        private static void GenerateFields(DomNodeType nodeType, string typeName, StringBuilder sb)
        {
            WriteLine(sb, "        public static class {0}", typeName);
            WriteLine(sb, "        {{");

            WriteLine(sb, "            public static DomNodeType Type;");
            foreach (AttributeInfo attributeInfo in nodeType.Attributes)
            {
                string attrInfoName = CreateIdentifier(attributeInfo.Name + "Attribute");
                WriteLine(sb, "            public static AttributeInfo {0};", attrInfoName);
            }
            foreach (ChildInfo child in nodeType.Children)
            {
                string childInfoName = CreateIdentifier(child.Name + "Child");
                WriteLine(sb, "            public static ChildInfo {0};", childInfoName);
            }

            WriteLine(sb, "        }}");
        }
Ejemplo n.º 53
0
 private static string GetClassName(DomNodeType nodeType, Dictionary <string, string> domNodeTypeToClassName)
 {
     return(domNodeTypeToClassName[nodeType.Name]);
 }
Ejemplo n.º 54
0
        public void Test()
        {
            XmlSchemaTypeLoader loader = new XmlSchemaTypeLoader();

            loader.SchemaResolver = new ResourceStreamResolver(
                Assembly.GetExecutingAssembly(),
                "UnitTests.Atf/Resources");
            loader.Load("testComplexTypes.xsd");

            DomNodeType abstractType = loader.GetNodeType("test:abstractType");

            Assert.IsTrue(abstractType != null);
            Assert.IsTrue(abstractType.IsAbstract);

            DomNodeType complexType1 = loader.GetNodeType("test:complexType1");

            Assert.IsTrue(complexType1 != null);
            Assert.IsTrue(!complexType1.IsAbstract);
            Assert.IsTrue(complexType1.BaseType == abstractType);
            //Assert.IsTrue(complexType1.FindAnnotation("annotation") != null);
            //Assert.IsTrue(complexType1.FindAnnotation("annotation", "attr1") != null);

            DomNodeType complexType2 = loader.GetNodeType("test:complexType2");

            Assert.IsTrue(complexType2 != null);
            Assert.IsTrue(!complexType2.IsAbstract);
            AttributeInfo attr1 = complexType2.GetAttributeInfo("attr1");

            Assert.IsTrue(attr1 != null);
            Assert.IsTrue(attr1.DefaultValue.Equals(1));
            //Assert.IsTrue(attr1.FindAnnotation("annotation") != null);
            AttributeInfo attr2 = complexType2.GetAttributeInfo("attr2");

            Assert.IsTrue(attr2 != null);
            Assert.IsTrue(attr2.DefaultValue.Equals(2));

            DomNodeType complexType3 = loader.GetNodeType("test:complexType3");

            Assert.IsTrue(complexType3 != null);
            Assert.IsTrue(!complexType3.IsAbstract);
            Assert.IsTrue(complexType3.BaseType == complexType2);
            AttributeInfo attr3 = complexType3.GetAttributeInfo("attr3");

            Assert.IsTrue(attr3 != null);
            ChildInfo elem1 = complexType3.GetChildInfo("elem1");

            Assert.IsTrue(elem1 != null);
            Assert.IsTrue(elem1.Type == complexType1);
            //Assert.IsTrue(elem1.FindAnnotation("annotation") != null);
            ChildInfo elem2 = complexType3.GetChildInfo("elem2");

            Assert.IsTrue(elem2 != null);
            Assert.IsTrue(elem2.Type == complexType1);
            Assert.IsTrue(MinMaxCheck(elem2, 1, 3));
            ChildInfo elem3 = complexType3.GetChildInfo("elem3");

            Assert.IsTrue(elem3 != null); //because a sequence of simple types becomes a sequence of child DomNodes
            attr3 = complexType3.GetAttributeInfo("elem3");
            Assert.IsTrue(attr3 == null); //because a sequence of simple types becomes a sequence of child DomNodes
            DomNode       node3                   = new DomNode(complexType3);
            DomNode       elem3Child1             = new DomNode(elem3.Type);
            AttributeInfo elem3ValueAttributeInfo = elem3.Type.GetAttributeInfo(string.Empty);

            elem3Child1.SetAttribute(elem3ValueAttributeInfo, 1);
            DomNode elem3Child2 = new DomNode(elem3.Type);

            elem3Child2.SetAttribute(elem3ValueAttributeInfo, 1);
            DomNode elem3Child3 = new DomNode(elem3.Type);

            elem3Child3.SetAttribute(elem3ValueAttributeInfo, 1);
            node3.GetChildList(elem3).Add(elem3Child1);
            node3.GetChildList(elem3).Add(elem3Child2);
            node3.GetChildList(elem3).Add(elem3Child3);

            IList <DomNode> node3Children = node3.GetChildList(elem3);

            Assert.IsTrue((int)node3Children[0].GetAttribute(elem3ValueAttributeInfo) == 1);
            Assert.IsTrue((int)node3Children[1].GetAttribute(elem3ValueAttributeInfo) == 1);
            Assert.IsTrue((int)node3Children[2].GetAttribute(elem3ValueAttributeInfo) == 1);

            // Update on 8/16/2011. DomXmlReader would not be able to handle a sequence of elements
            //  of a simple type like this. When reading, each subsequent element's value would be
            //  used to set the attribute on the DomNode, overwriting the previous one. So, since
            //  this behavior of converting more than one element of a simple type into an attribute
            //  array was broken, I want to change this unit test that I wrote and make sequences of
            //  elements of simple types into a sequence of DomNode children with a value attribute.
            //  (A value attribute means an attribute whose name is "".) --Ron
            //ChildInfo elem3 = complexType3.GetChildInfo("elem3");
            //Assert.IsTrue(elem3 == null); //because a sequence of simple types becomes an attribute
            //attr3 = complexType3.GetAttributeInfo("elem3");
            //Assert.IsTrue(attr3 != null); //because a sequence of simple types becomes an attribute
            //DomNode node3 = new DomNode(complexType3);
            //object attr3Obj = node3.GetAttribute(attr3);
            //Assert.IsTrue(
            //    attr3Obj is int &&
            //    (int)attr3Obj == 0); //the default integer
            //node3.SetAttribute(attr3, 1);
            //attr3Obj = node3.GetAttribute(attr3);
            //Assert.IsTrue(
            //    attr3Obj is int &&
            //    (int)attr3Obj == 1);
            //node3.SetAttribute(attr3, new int[] { 1, 2, 3 });
            //attr3Obj = node3.GetAttribute(attr3);
            //Assert.IsTrue(
            //    attr3Obj is int[] &&
            //    ((int[])attr3Obj)[2]==3);

            DomNodeType complexType4 = loader.GetNodeType("test:complexType4");

            Assert.IsTrue(complexType4 != null);
            Assert.IsTrue(!complexType4.IsAbstract);
            attr1 = complexType4.GetAttributeInfo("attr1");
            Assert.IsTrue(attr1 != null);
            elem1 = complexType4.GetChildInfo("elem1");
            Assert.IsTrue(elem1 != null);
            Assert.IsTrue(elem1.Type == complexType3);
            Assert.IsTrue(MinMaxCheck(elem1, 1, 1));

            DomNodeType complexType5 = loader.GetNodeType("test:complexType5");

            Assert.IsTrue(complexType5 != null);
            Assert.IsTrue(!complexType5.IsAbstract);
            elem1 = complexType5.GetChildInfo("elem1");
            Assert.IsTrue(elem1 != null);
            Assert.IsTrue(elem1.Type == abstractType);
            Assert.IsTrue(MinMaxCheck(elem1, 1, Int32.MaxValue));

            DomNode node5 = new DomNode(complexType5);

            elem2 = complexType5.GetChildInfo("elem2");
            DomNode node2 = new DomNode(complexType2);

            node5.SetChild(elem2, node2);
            node5.SetChild(elem2, null);
            node3 = new DomNode(complexType3);
            elem3 = complexType5.GetChildInfo("elem3");
            node5.SetChild(elem3, node3);
            //The following should violate xs:choice, but we don't fully support this checking yet.
            //ExceptionTester.CheckThrow<InvalidOperationException>(delegate { node5.AddChild(elem2, node2); });

            DomNodeType complexType6 = loader.GetNodeType("test:complexType6");

            Assert.IsTrue(complexType6 != null);
            Assert.IsTrue(!complexType6.IsAbstract);
            elem1 = complexType6.GetChildInfo("elem1");
            Assert.IsTrue(elem1 != null);
            Assert.IsTrue(elem1.Type == abstractType);
            Assert.IsTrue(MinMaxCheck(elem1, 1, Int32.MaxValue));
            elem2 = complexType6.GetChildInfo("elem2");
            Assert.IsTrue(elem2 != null);
            Assert.IsTrue(elem2.Type == complexType2);
            Assert.IsTrue(MinMaxCheck(elem2, 1, Int32.MaxValue));

            //DomNodeType complexType7 = loader.GetNodeType("test:complexType7");
            //Assert.IsTrue(complexType7 != null);
            //Assert.IsTrue(!complexType7.IsAbstract);
            //AttributeInfo attrSimpleSequence = complexType7.GetAttributeInfo("elemSimpleSequence");
            //Assert.IsTrue(attrSimpleSequence == null); //because a sequence of simple types becomes a sequence of child DomNodes
            //ChildInfo elemSimpleSequence = complexType7.GetChildInfo("elemSimpleSequence");
            //Assert.IsTrue(elemSimpleSequence != null); //because a sequence of simple types becomes a sequence of child DomNodes
            //DomNode node7 = new DomNode(complexType7);
            //object attrObj7 = node7.GetAttribute(attrSimpleSequence);
            //Assert.IsTrue(
            //    attrObj7 is float[] &&
            //    ((float[])attrObj7)[0] == 0 &&
            //    ((float[])attrObj7)[1] == 0 &&
            //    ((float[])attrObj7)[2] == 0); //the default vector
            //float[][] newSequence =
            //{
            //    new float[] {1, 2, 3},
            //    new float[] {4, 5, 6},
            //    new float[] {7, 8, 9}
            //};
            //node7.SetAttribute(attrSimpleSequence, newSequence);
            //attrObj7 = node7.GetAttribute(attrSimpleSequence);
            //Assert.IsTrue(ArraysEqual(attrObj7, newSequence));
        }
Ejemplo n.º 55
0
 private static bool IsDerivedFrom(DomNode node, DomNodeType type)
 {
     return(node.Type.Lineage.FirstOrDefault(t => t == type) != null);
 }
Ejemplo n.º 56
0
        protected override void ParseAnnotations(
            XmlSchemaSet schemaSet,
            IDictionary <NamedMetadata, IList <XmlNode> > annotations)
        {
            base.ParseAnnotations(schemaSet, annotations);

            foreach (var kv in annotations)
            {
                DomNodeType nodeType = kv.Key as DomNodeType;
                if (kv.Value.Count == 0)
                {
                    continue;
                }

                // create a hash of hidden attributes
                HashSet <string> hiddenprops = new HashSet <string>();
                foreach (XmlNode xmlnode in kv.Value)
                {
                    if (xmlnode.LocalName == "scea.dom.editors.attribute")
                    {
                        XmlAttribute hiddenAttrib = xmlnode.Attributes["hide"];
                        if (hiddenAttrib != null && hiddenAttrib.Value == "true")
                        {
                            XmlAttribute nameAttrib = xmlnode.Attributes["name"];
                            string       name       = (nameAttrib != null) ? nameAttrib.Value : null;
                            if (!string.IsNullOrWhiteSpace(name))
                            {
                                hiddenprops.Add(name);
                            }
                        }

                        LevelEditorXLE.Patches.PatchSchemaAnnotation(xmlnode);
                    }
                }

                if (hiddenprops.Count > 0)
                {
                    nodeType.SetTag(HiddenProperties, hiddenprops);
                }

                PropertyDescriptorCollection localDescriptor      = nodeType.GetTagLocal <PropertyDescriptorCollection>();
                PropertyDescriptorCollection annotationDescriptor = Sce.Atf.Dom.PropertyDescriptor.ParseXml(nodeType, kv.Value);

                // if the type already have local property descriptors
                // then add annotation driven property descriptors to it.
                if (localDescriptor != null)
                {
                    foreach (System.ComponentModel.PropertyDescriptor propDecr in annotationDescriptor)
                    {
                        localDescriptor.Add(propDecr);
                    }
                }
                else
                {
                    localDescriptor = annotationDescriptor;
                }

                if (localDescriptor.Count > 0)
                {
                    nodeType.SetTag <PropertyDescriptorCollection>(localDescriptor);
                }


                // process annotations resourceReferenceTypes.
                XmlNode rfNode = FindElement(kv.Value, Annotations.ReferenceConstraint.Name);
                if (rfNode != null)
                {
                    HashSet <string> extSet = null;
                    string           exts   = FindAttribute(rfNode, Annotations.ReferenceConstraint.ValidResourceFileExts);
                    if (!string.IsNullOrWhiteSpace(exts))
                    {
                        exts = exts.ToLower();
                        char[] sep = { ',' };
                        extSet = new HashSet <string>(exts.Split(sep, StringSplitOptions.RemoveEmptyEntries));
                    }
                    else if (m_gameEngine != null)
                    {
                        string       restype = FindAttribute(rfNode, Annotations.ReferenceConstraint.ResourceType);
                        ResourceInfo resInfo = m_gameEngine.Info.ResourceInfos.GetByType(restype);
                        if (resInfo != null)
                        {
                            extSet = new HashSet <string>(resInfo.FileExts);
                        }
                    }

                    if (extSet != null)
                    {
                        nodeType.SetTag(Annotations.ReferenceConstraint.ValidResourceFileExts, extSet);
                    }

                    nodeType.SetTag(
                        Annotations.ReferenceConstraint.ResourceType,
                        FindAttribute(rfNode, Annotations.ReferenceConstraint.ResourceType));
                }

                // todo use schema annotation to mark  Palette types.
                XmlNode xmlNode = FindElement(kv.Value, "scea.dom.editors");
                if (xmlNode != null)
                {
                    string name        = FindAttribute(xmlNode, "name");
                    string description = FindAttribute(xmlNode, "description");
                    string image       = FindAttribute(xmlNode, "image");
                    string category    = FindAttribute(xmlNode, "category");
                    string menuText    = FindAttribute(xmlNode, "menuText");
                    if (!string.IsNullOrEmpty(category))
                    {
                        NodeTypePaletteItem item = new NodeTypePaletteItem(nodeType, name, description, image, category, menuText);
                        nodeType.SetTag <NodeTypePaletteItem>(item);
                    }
                }

                // handle special extensions
                foreach (XmlNode annot in kv.Value)
                {
                    if (annot.LocalName == "LeGe.OpaqueListable")
                    {
                        var labelAttrib = annot.Attributes["label"];
                        if (labelAttrib != null)
                        {
                            string label = labelAttrib.Value;
                            nodeType.SetTag("OpaqueListable", label);
                        }
                        nodeType.Define(new ExtensionInfo <DomNodeAdapters.OpaqueListable>());
                    }
                    else if (annot.LocalName == "LeGe.GameObjectProperties")
                    {
                        nodeType.Define(new ExtensionInfo <DomNodeAdapters.GameObjectProperties>());
                    }
                    else if (annot.LocalName == "LeGe.TransformUpdater")
                    {
                        nodeType.Define(new ExtensionInfo <DomNodeAdapters.TransformUpdater>());
                    }
                    else if (annot.LocalName == "LeGe.TransformObject")
                    {
                        nodeType.Define(new ExtensionInfo <DomNodeAdapters.TransformObject>());
                    }
                    else if (annot.LocalName == "LeGe.GameContext")
                    {
                        nodeType.Define(new ExtensionInfo <GameContext>());
                    }
                    else if (annot.LocalName == "LeGe.VisibleLockable")
                    {
                        nodeType.Define(new ExtensionInfo <DomNodeAdapters.VisibleLockable>());
                    }
                }
            }
        }
Ejemplo n.º 57
0
        public void TestAttributeChangedEvents()
        {
            DomNodeType   type           = new DomNodeType("type");
            AttributeInfo stringTypeInfo = GetStringAttribute("string");
            AttributeInfo intTypeInfo    = GetIntAttribute("int");

            type.Define(stringTypeInfo);
            type.Define(intTypeInfo);
            DomNode test = new DomNode(type);

            test.AttributeChanging += new EventHandler <AttributeEventArgs>(test_AttributeChanging);
            test.AttributeChanged  += new EventHandler <AttributeEventArgs>(test_AttributeChanged);
            AttributeEventArgs expected;

            // test for no value change if setting to the default value and attribute is already the default
            AttributeChangingArgs = null;
            AttributeChangedArgs  = null;
            test.SetAttribute(stringTypeInfo, stringTypeInfo.DefaultValue);
            Assert.Null(AttributeChangingArgs);
            Assert.Null(AttributeChangedArgs);
            test.SetAttribute(intTypeInfo, intTypeInfo.DefaultValue);
            Assert.Null(AttributeChangingArgs);
            Assert.Null(AttributeChangedArgs);

            // test for value change, string type
            test = new DomNode(type);
            test.AttributeChanging += new EventHandler <AttributeEventArgs>(test_AttributeChanging);
            test.AttributeChanged  += new EventHandler <AttributeEventArgs>(test_AttributeChanged);
            AttributeChangingArgs   = null;
            AttributeChangedArgs    = null;
            object oldValue = test.GetAttribute(stringTypeInfo);

            test.SetAttribute(stringTypeInfo, "foo");
            expected = new AttributeEventArgs(test, stringTypeInfo, oldValue, "foo");
            Assert.True(Equals(AttributeChangingArgs, expected));
            Assert.True(Equals(AttributeChangedArgs, expected));

            oldValue = test.GetAttribute(stringTypeInfo);
            test.SetAttribute(stringTypeInfo, "foobar");
            expected = new AttributeEventArgs(test, stringTypeInfo, oldValue, "foobar");
            Assert.True(Equals(AttributeChangingArgs, expected));
            Assert.True(Equals(AttributeChangedArgs, expected));

            // test for value change, int type
            AttributeChangingArgs = null;
            AttributeChangedArgs  = null;
            oldValue = test.GetAttribute(intTypeInfo);
            test.SetAttribute(intTypeInfo, 5);
            expected = new AttributeEventArgs(test, intTypeInfo, oldValue, 5);
            Assert.True(Equals(AttributeChangingArgs, expected));
            Assert.True(Equals(AttributeChangedArgs, expected));

            oldValue = test.GetAttribute(intTypeInfo);
            test.SetAttribute(intTypeInfo, 7);
            expected = new AttributeEventArgs(test, intTypeInfo, oldValue, 7);
            Assert.True(Equals(AttributeChangingArgs, expected));
            Assert.True(Equals(AttributeChangedArgs, expected));

            // test for no value change
            test.SetAttribute(stringTypeInfo, "foo");
            AttributeChangingArgs = null;
            AttributeChangedArgs  = null;
            test.SetAttribute(stringTypeInfo, "foo");
            Assert.Null(AttributeChangingArgs);
            Assert.Null(AttributeChangedArgs);

            test.SetAttribute(intTypeInfo, 9);
            AttributeChangingArgs = null;
            AttributeChangedArgs  = null;
            test.SetAttribute(intTypeInfo, 9);
            Assert.Null(AttributeChangingArgs);
            Assert.Null(AttributeChangedArgs);
        }
Ejemplo n.º 58
0
        /// <summary>
        /// Finishes initializing component by adding palette information and defining module types</summary>
        public virtual void Initialize()
        {
            // add palette info to annotation type, and register with palette
            var annotationItem = new NodeTypePaletteItem(
                Schema.annotationType.Type,
                "Comment".Localize(),
                "Create a moveable resizable comment on the circuit canvas".Localize(),
                Resources.AnnotationImage);

            m_paletteService.AddItem(annotationItem, PaletteCategory, this);

            // define editable properties on annotation
            Schema.annotationType.Type.SetTag(
                new PropertyDescriptorCollection(
                    new PropertyDescriptor[] {
                new AttributePropertyDescriptor(
                    "Text".Localize(),
                    Schema.annotationType.textAttribute,
                    null,
                    "Comment Text".Localize(),
                    false),
                new AttributePropertyDescriptor(
                    "BackColor".Localize(),                                  // name
                    Schema.annotationType.backcolorAttribute,                //AttributeInfo
                    null,                                                    // category
                    "Comment background color".Localize(),                   //description
                    false,                                                   //isReadOnly
                    new Sce.Atf.Controls.PropertyEditing.ColorEditor(),      // editor
                    new Sce.Atf.Controls.PropertyEditing.IntColorConverter() // typeConverter
                    ),
                new AttributePropertyDescriptor(
                    "ForeColor".Localize(),                                  // name
                    Schema.annotationType.foreColorAttribute,                //AttributeInfo
                    null,                                                    // category
                    "Comment foreground color".Localize(),                   //description
                    false,                                                   //isReadOnly
                    new Sce.Atf.Controls.PropertyEditing.ColorEditor(),      // editor
                    new Sce.Atf.Controls.PropertyEditing.IntColorConverter() // typeConverter
                    ),
            }));

            // define module types

            DefineModuleType(
                new XmlQualifiedName("buttonType", Schema.NS),
                "Button".Localize(),
                "On/Off Button".Localize(),
                Resources.ButtonImage,
                EmptyArray <ElementType.Pin> .Instance,
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), BooleanPinTypeName, 0)
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("lightType", Schema.NS),
                "Light".Localize(),
                "Light source".Localize(),
                Resources.LightImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In".Localize(), BooleanPinTypeName, 0)
            },
                EmptyArray <ElementType.Pin> .Instance,
                m_schemaLoader);

            DomNodeType speakerNodeType = DefineModuleType(
                new XmlQualifiedName("speakerType", Schema.NS),
                "Speaker".Localize("an electronic speaker, for playing sounds"),
                "Speaker".Localize("an electronic speaker, for playing sounds"),
                Resources.SpeakerImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In".Localize(), FloatPinTypeName, 0),
            },
                EmptyArray <ElementType.Pin> .Instance,
                m_schemaLoader);
            var speakerManufacturerInfo = new AttributeInfo("Manufacturer".Localize(), AttributeType.StringType);

            speakerNodeType.Define(speakerManufacturerInfo);
            speakerNodeType.SetTag(
                new PropertyDescriptorCollection(
                    new PropertyDescriptor[] {
                new AttributePropertyDescriptor(
                    "Manufacturer".Localize(),
                    speakerManufacturerInfo,
                    null,                      //category
                    "Manufacturer".Localize(), //description
                    false)                     //is not read-only
            }));

            DefineModuleType(
                new XmlQualifiedName("soundType", Schema.NS),
                "Sound".Localize(),
                "Sound Player".Localize(),
                Resources.SoundImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("On".Localize(), "boolean", 0),
                new ElementType.Pin("Reset".Localize(), "boolean", 1),
                new ElementType.Pin("Pause".Localize(), "boolean", 2),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "float", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("andType", Schema.NS),
                "And".Localize(),
                "Logical AND".Localize(),
                Resources.AndImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In1".Localize("input pin #1"), "boolean", 0),
                new ElementType.Pin("In2".Localize("input pin #2"), "boolean", 1),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "boolean", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("orType", Schema.NS),
                "Or".Localize(),
                "Logical OR".Localize(),
                Resources.OrImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In1".Localize("input pin #1"), "boolean", 0),
                new ElementType.Pin("In2".Localize("input pin #2"), "boolean", 1),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "boolean", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("16To1MultiplexerType", Schema.NS),
                "16-to-1 Multiplexer".Localize(),
                "16-to-1 Multiplexer".Localize(),
                Resources.AndImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("In1".Localize(), "boolean", 0),
                new ElementType.Pin("In2".Localize(), "boolean", 1),
                new ElementType.Pin("In3".Localize(), "boolean", 2),
                new ElementType.Pin("In4".Localize(), "boolean", 3),
                new ElementType.Pin("In5".Localize(), "boolean", 4),
                new ElementType.Pin("In6".Localize(), "boolean", 5),
                new ElementType.Pin("In7".Localize(), "boolean", 6),
                new ElementType.Pin("In8".Localize(), "boolean", 7),
                new ElementType.Pin("In9".Localize(), "boolean", 8),
                new ElementType.Pin("In10".Localize(), "boolean", 9),
                new ElementType.Pin("In11".Localize(), "boolean", 10),
                new ElementType.Pin("In12".Localize(), "boolean", 11),
                new ElementType.Pin("In13".Localize(), "boolean", 12),
                new ElementType.Pin("In14".Localize(), "boolean", 13),
                new ElementType.Pin("In15".Localize(), "boolean", 14),
                new ElementType.Pin("In16".Localize(), "boolean", 15),
                new ElementType.Pin("Select1".Localize(), "boolean", 16),
                new ElementType.Pin("Select2".Localize(), "boolean", 17),
                new ElementType.Pin("Select3".Localize(), "boolean", 18),
                new ElementType.Pin("Select4".Localize(), "boolean", 19),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out".Localize(), "boolean", 0),
            },
                m_schemaLoader);

            DefineModuleType(
                new XmlQualifiedName("1To16DemultiplexerType", Schema.NS),
                "1-to-16 Demultiplexer".Localize(),
                "1-to-16 Demultiplexer".Localize(),
                Resources.OrImage,
                new ElementType.Pin[]
            {
                new ElementType.Pin("Data".Localize(), "boolean", 0),
                new ElementType.Pin("Select1".Localize(), "boolean", 1),
                new ElementType.Pin("Select2".Localize(), "boolean", 2),
                new ElementType.Pin("Select3".Localize(), "boolean", 3),
                new ElementType.Pin("Select4".Localize(), "boolean", 4),
            },
                new ElementType.Pin[]
            {
                new ElementType.Pin("Out1".Localize(), "boolean", 0),
                new ElementType.Pin("Out2".Localize(), "boolean", 1),
                new ElementType.Pin("Out3".Localize(), "boolean", 2),
                new ElementType.Pin("Out4".Localize(), "boolean", 3),
                new ElementType.Pin("Out5".Localize(), "boolean", 4),
                new ElementType.Pin("Out6".Localize(), "boolean", 5),
                new ElementType.Pin("Out7".Localize(), "boolean", 6),
                new ElementType.Pin("Out8".Localize(), "boolean", 7),
                new ElementType.Pin("Out9".Localize(), "boolean", 8),
                new ElementType.Pin("Out10".Localize(), "boolean", 9),
                new ElementType.Pin("Out11".Localize(), "boolean", 10),
                new ElementType.Pin("Out12".Localize(), "boolean", 11),
                new ElementType.Pin("Out13".Localize(), "boolean", 12),
                new ElementType.Pin("Out14".Localize(), "boolean", 13),
                new ElementType.Pin("Out15".Localize(), "boolean", 14),
                new ElementType.Pin("Out16".Localize(), "boolean", 15),
            },
                m_schemaLoader);
        }
Ejemplo n.º 59
0
 public static bool IsReferenceType(DomNodeType nodeType)
 {
     return(Schema.placementsCellReferenceType.Type.IsAssignableFrom(nodeType));
 }
Ejemplo n.º 60
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="nodeType">DomNodeType to copy</param>
 public DomNodeTypeRootCopier(DomNodeType nodeType)
 {
     m_nodeType = nodeType;
 }