Example #1
0
        public void TestGetDescription()
        {
            CompositeType type = CreateSampleType();

            Assert.AreEqual("ItemDescr1", type.GetDescription("ItemName1"));
            Assert.AreEqual("ItemDescr2", type.GetDescription("ItemName2"));
            Assert.AreEqual(null, type.GetDescription("ItemName3"));
        }
Example #2
0
        public void MappersUseDescriptionsFromResourceFile()
        {
            OpenTypeKind mapsTo;

            Assert.IsTrue(mapper.CanHandle(typeof(ResourceTestType), out mapsTo, CanHandle));
            Assert.AreEqual(OpenTypeKind.CompositeType, mapsTo);

            OpenType mappedType = mapper.MapType(typeof(ResourceTestType), MapType);

            Assert.AreEqual(OpenTypeKind.CompositeType, mappedType.Kind);

            CompositeType compositeType = (CompositeType)mappedType;

            Assert.AreEqual(ResourceUsageTest.ResourceTestType, compositeType.Description);
            Assert.IsTrue(compositeType.ContainsKey("IntValue"));
            Assert.IsTrue(compositeType.ContainsKey("StringValue"));
            Assert.AreEqual(ResourceUsageTest.IntValue, compositeType.GetDescription("IntValue"));
            Assert.AreEqual(ResourceUsageTest.StringValue, compositeType.GetDescription("StringValue"));
        }
Example #3
0
        public CompositeDataType_Type(CompositeType value)
            : base(value)
        {
            List <CompositeDataField> fields = new List <CompositeDataField>();

            foreach (string fieldName in value.KeySet)
            {
                fields.Add(new CompositeDataField(fieldName, value.GetDescription(fieldName), Serialize(value.GetOpenType(fieldName))));
            }
            CompositeDataField = fields.ToArray();
        }
Example #4
0
        private static CompositeType MakeElementType(CompositeType rowType)
        {
            List <string>   names        = new List <string>();
            List <string>   descriptions = new List <string>();
            List <OpenType> types        = new List <OpenType>();

            foreach (string itemName in rowType.KeySet)
            {
                if (itemName != CollectionIndexColumnName)
                {
                    names.Add(itemName);
                    descriptions.Add(rowType.GetDescription(itemName));
                    types.Add(rowType.GetOpenType(itemName));
                }
            }
            return(new CompositeType(rowType.TypeName, rowType.Description, names, descriptions, types));
        }
Example #5
0
        private static CompositeType MakeRowType(CompositeType elementType)
        {
            List <string>   names        = new List <string>();
            List <string>   descriptions = new List <string>();
            List <OpenType> types        = new List <OpenType>();

            names.Add(CollectionIndexColumnName);
            descriptions.Add("Index of a collection");
            types.Add(SimpleType.Integer);

            foreach (string itemName in elementType.KeySet)
            {
                names.Add(itemName);
                descriptions.Add(elementType.GetDescription(itemName));
                types.Add(elementType.GetOpenType(itemName));
            }
            return(new CompositeType(elementType.TypeName, elementType.Description, names, descriptions, types));
        }