コード例 #1
0
        public object MapToIdlEnum(Type clsType)
        {
            string[] names  = Enum.GetNames(clsType);
            EnumTC   result = new EnumTC(Repository.GetRepositoryID(clsType),
                                         IdlNaming.ReverseIdlToClsNameMapping(clsType.Name),
                                         names);

            RegisterCreatedTypeCodeForType(clsType, AttributeExtCollection.EmptyCollection,
                                           result);
            return(result);
        }
コード例 #2
0
        public void TestGenerateSpecialNameRepId()
        {
            string name     = "TestEnumGenForTypeCodeType3";
            string typeName = "Ch.Elca.Iiop.Tests." + name;
            string repId    = "IDL:Ch/Elca/Iiop/Tests/Special_TestEnumGenForTypeCodeType3:1.0";
            EnumTC tc       = new EnumTC(repId,
                                         name,
                                         new string[] { name + "_1", name + "_2" });

            Type res = m_gen.CreateOrGetType(typeName, tc);

            Assert.NotNull(res);
            Assert.AreEqual(typeName, res.FullName, "type name");
            Assert.AreEqual(repId, Repository.GetRepositoryID(res), "rep id");
        }
コード例 #3
0
        public void TestGenerate()
        {
            string name     = "TestEnumGenForTypeCodeType";
            string typeName = "Ch.Elca.Iiop.Tests." + name;
            string repId    = "IDL:Ch/Elca/Iiop/Tests/TestEnumGenForTypeCodeType:1.0";

            string[] enumFields = new string[] { name + "_1", name + "_2" };
            EnumTC   tc         = new EnumTC(repId,
                                             name,
                                             enumFields);

            Type res = m_gen.CreateOrGetType(typeName, tc);

            Assert.NotNull(res);
            Assert.AreEqual(typeName, res.FullName, "type name");
            Assert.AreEqual(repId, Repository.GetRepositoryID(res), "rep id");
            string[] genEnumNames = Enum.GetNames(res);
            Assert.AreEqual(enumFields.Length, genEnumNames.Length, "nr of enum entries");
            Assert.AreEqual(enumFields[0], genEnumNames[0], "enum entry 1");
            Assert.AreEqual(enumFields[1], genEnumNames[1], "enum entry 2");
            Assert.IsTrue(res.IsSerializable, "Serializable");
        }