public void TestGenerateSpecialNameRepId()
 {
     string name = "TestStructGenForTypeCodeType3";
     string typeName = "Ch.Elca.Iiop.Tests." + name;
     string repId = "IDL:Ch/Elca/Iiop/Tests/Special_TestStructGenForTypeCodeType3:1.0";
     StructTC tc = new StructTC(repId,
                                name, new StructMember[] {
                                new StructMember("M1", new LongTC()) });
     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");
 }
Esempio n. 2
0
 public object MapToIdlStruct(Type clsType) {
     lock(structTCs)
     {
         StructTC result = structTCs[clsType] as StructTC;
         if(result != null)
             return result;
     
         result = new StructTC();
         RegisterCreatedTypeCodeForType(clsType, AttributeExtCollection.EmptyCollection,
                                        result);
         
         FieldInfo[] members = ReflectionHelper.GetAllDeclaredInstanceFieldsOrdered(clsType);
         StructMember[] structMembers = new StructMember[members.Length];
         for (int i = 0; i < members.Length; i++) {                
             omg.org.CORBA.TypeCode memberType = 
                 CreateOrGetTypeCodeForType(members[i].FieldType,
                                            ReflectionHelper.GetCustomAttriutesForField(members[i], 
                                                                                        true));
             structMembers[i] = new StructMember(members[i].Name, memberType);
         }
         result.Initalize(Repository.GetRepositoryID(clsType), 
                          IdlNaming.ReverseIdlToClsNameMapping(clsType.Name),
                          structMembers);
         
         structTCs[clsType] = result;
         
         return result;
     }
 }
 public void TestGenerate()
 {
     string name = "TestStructGenForTypeCodeType";
     string typeName = "Ch.Elca.Iiop.Tests." + name;
     string repId = "IDL:Ch/Elca/Iiop/Tests/TestStructGenForTypeCodeType:1.0";
     StructMember m1 = new StructMember("M1", new LongTC());
     StructTC tc = new StructTC(repId,
                                name, new StructMember[] {
                                m1 });
     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");
     Assert.NotNull(res.GetField(m1.name,
                                          BindingFlags.Public | BindingFlags.Instance), "field M1");
     Assert.IsTrue(res.IsSerializable, "Serializable");
 }