예제 #1
0
 internal override void ReadFromStream(CdrInputStream cdrStream,
                                       SerializerFactory serFactory)
 {
     CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation();
     m_id = ReadRepositoryId(encap);
     m_name = encap.ReadString();
     m_typeMod = encap.ReadShort();
     TypeCodeSerializer ser = new TypeCodeSerializer(serFactory);
     m_baseClass = (TypeCode)ser.Deserialize(encap);
     // deser members
     uint length = encap.ReadULong();
     m_members = new ValueMember[length];
     for (int i = 0; i < length; i++)
     {
         string memberName = encap.ReadString();
         TypeCode memberType = (TypeCode)ser.Deserialize(encap);
         short visibility = encap.ReadShort();
         ValueMember member = new ValueMember(memberName, memberType, visibility);
         m_members[i] = member;
     }
 }
예제 #2
0
 public void Initalize(string repositoryID, string name, ValueMember[] members, TypeCode baseClass, short typeMod)
 {
     m_id = repositoryID;
     m_name = name;
     m_members = members;
     if (m_members == null) { m_members = new ValueMember[0]; }
     m_baseClass = baseClass;
     m_typeMod = typeMod;
 }
예제 #3
0
 public ValueTypeTC(string repositoryID, string name, ValueMember[] members, TypeCode baseClass, short typeMod)
     : base(TCKind.tk_value)
 {
     Initalize(repositoryID, name, members, baseClass, typeMod);
 }
예제 #4
0
 public object MapToIdlConcreateValueType(Type clsType) {
     omg.org.CORBA.TypeCode baseTypeCode;
     if (clsType.BaseType.Equals(ReflectionHelper.ObjectType) || 
         clsType.BaseType.Equals(typeof(System.ComponentModel.MarshalByValueComponent))) {
         baseTypeCode = new NullTC();
     } else {
         baseTypeCode = CreateOrGetTypeCodeForType(clsType.BaseType, 
                                                   AttributeExtCollection.EmptyCollection);
     }
     ValueTypeTC result = new ValueTypeTC();
     RegisterCreatedTypeCodeForType(clsType, AttributeExtCollection.EmptyCollection,
                                    result);                        
     
     // create the TypeCodes for the members
     FieldInfo[] members = ReflectionHelper.GetAllDeclaredInstanceFieldsOrdered(clsType);
     ValueMember[] valueMembers = new ValueMember[members.Length];
     for (int i = 0; i < members.Length; i++) {
         omg.org.CORBA.TypeCode memberType = CreateOrGetTypeCodeForType(members[i].FieldType, 
                                                 ReflectionHelper.GetCustomAttriutesForField(members[i], 
                                                                                             true));
         short visibility;
         if (members[i].IsPrivate) { 
             visibility = VISIBILITY_PRIVATE; 
         } else { 
             visibility = VISIBILITY_PUBLIC; 
         }
         valueMembers[i] = new ValueMember(members[i].Name, memberType, visibility);
     }
     result.Initalize(Repository.GetRepositoryID(clsType),
                      IdlNaming.ReverseIdlToClsNameMapping(clsType.Name),
                      valueMembers, baseTypeCode, CONCRETE_VALUE_MOD);
     return result;
 }
예제 #5
0
        public void TestValueTypeTC()
        {
            string name = "OrbServices_TestValueType";
            string repId = "IDL:Ch/Elca/Iiop/Tests/" + name + ":1.0";

            ValueMember m1 = new ValueMember("M1", m_orb.create_long_tc(), 0);
            omg.org.CORBA.TypeCode tc =
                m_orb.create_value_tc(repId, name, 0, m_orb.create_null_tc(),
                                      new ValueMember[] { m1 });
            Assert.AreEqual(repId, tc.id(), "id");
            Assert.AreEqual(TCKind.tk_value, tc.kind(), "king");
            Assert.AreEqual(1, tc.member_count(), "nr of members");
            Assert.AreEqual(m1.name, tc.member_name(0), "member m1 name");
            Assert.AreEqual(m1.type.kind(), tc.member_type(0).kind(), "member m1 type");
        }
        public void TestGenerate()
        {
            string name = "TestGenForTypeCodeType";
            string typeName = "Ch.Elca.Iiop.Tests." + name;
            string repId = "IDL:Ch/Elca/Iiop/Tests/TestGenForTypeCodeType:1.0";
            ValueMember m1 = new ValueMember("M1", new LongTC(), 0);
            ValueTypeTC vt = new ValueTypeTC(repId,
                                             name, new ValueMember[] { m1 },
                                             new NullTC(), 0);

            Type res = m_gen.CreateOrGetType(typeName, vt);
            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");
        }