public void TestGenerateSpecialNameRepId()
        {
            string name = "TestBoxedGenForTypeCodeType3";
            string typeName = "Ch.Elca.Iiop.Tests." + name;
            string repId = "IDL:Ch/Elca/Iiop/Tests/Special_TestBoxedGenForTypeCodeType3:1.0";
            LongTC boxedTC = new LongTC();
            ValueBoxTC vt = new ValueBoxTC(repId,
                                           name,
                                           boxedTC);

            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");
        }
        private object MapToIdlBoxedValueType(Type clsType,
                                              bool boxInAny) {
            // dotNetType is subclass of BoxedValueBase
            if (!clsType.IsSubclassOf(ReflectionHelper.BoxedValueBaseType)) {
                // mapper error: MapToIdlBoxedValue found incorrect type
                throw new INTERNAL(1929, CompletionStatus.Completed_MayBe);
            }
            Type boxedType;
            object[] attributesOnBoxed = new object[0];
            try {
                boxedType = (Type)clsType.InvokeMember(BoxedValueBase.GET_BOXED_TYPE_METHOD_NAME,
                                                       BindingFlags.InvokeMethod | BindingFlags.Public |
                                                       BindingFlags.NonPublic | BindingFlags.Static | 
                                                       BindingFlags.DeclaredOnly, 
                                                       null, null, new object[0]);

                attributesOnBoxed = (object[])clsType.InvokeMember(BoxedValueBase.GET_BOXED_TYPE_ATTRIBUTES_METHOD_NAME,
                                                            BindingFlags.InvokeMethod | BindingFlags.Public |
                                                            BindingFlags.NonPublic | BindingFlags.Static | 
                                                            BindingFlags.DeclaredOnly, 
                                                            null, null, new object[0]);
            } 
            catch (Exception) {
                // invalid type: clsType
                // static method missing or not callable:
                // BoxedValueBase.GET_BOXED_TYPE_METHOD_NAME
                throw new INTERNAL(1930, CompletionStatus.Completed_MayBe);
            }
            if (boxInAny) {
                omg.org.CORBA.TypeCode boxed = CreateOrGetTypeCodeForType(boxedType, 
                                                                          AttributeExtCollection.ConvertToAttributeCollection(attributesOnBoxed));
            
                ValueBoxTC result = new ValueBoxTC(Repository.GetRepositoryID(clsType), 
                                                   IdlNaming.ReverseIdlToClsNameMapping(clsType.Name),
                                                   boxed);
                RegisterCreatedTypeCodeForType(clsType, AttributeExtCollection.EmptyCollection, result);
                return result;                                
            } else {
                // don't use boxed form
                // therefore create a typecode for the type boxed inside
                // e.g. in case of a boxed sequence of int, there will be a idlsequence typecode with int as element type created.
                // e.g. in case, where a sequence of boxed valuetype is boxed, an idl sequence will be created containing a typecode
                // for the boxed type.
                omg.org.CORBA.TypeCodeImpl forBoxed = CreateOrGetTypeCodeForType(boxedType, 
                                                                                 AttributeExtCollection.ConvertToAttributeCollection(attributesOnBoxed));
                return forBoxed;                
            }                                                              
        }
Exemple #3
0
        public void BoxBoxedValueTypeFromBoxed()
        {
            omg.org.CORBA.TypeCode tc =
                new ValueBoxTC("IDL:omg.org/CORBA/StringValue:1.0", "StringValue",
                               new StringTC());
            StringValue toBoxInto = new StringValue("test");
            Any anyContainer = new Any(toBoxInto, tc);
            Assert.AreEqual(tc, anyContainer.Type, "wrong tc");
            Assert.AreEqual(toBoxInto,
                                   anyContainer.ValueInternalRepresenation, "wrong val");
            Assert.AreEqual(ReflectionHelper.StringValueType,
                                   anyContainer.ValueInternalRepresenation.GetType(), "wrong val type");

            Assert.AreEqual(toBoxInto.Unbox(),
                                   anyContainer.Value, "wrong val");
            Assert.AreEqual(ReflectionHelper.StringType,
                                   anyContainer.Value.GetType(), "wrong val type");
        }