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); } }
internal override void ReadFromStream(CdrInputStream cdrStream, SerializerFactory serFactory) { CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation(); m_id = ReadRepositoryId(encap); m_name = encap.ReadString(); TypeCodeSerializer ser = new TypeCodeSerializer(serFactory); m_boxed = (TypeCodeImpl)ser.Deserialize(encap); }
public ValueBoxTC(string repositoryID, string name, TypeCode boxed) : base(TCKind.tk_value_box) { m_id = repositoryID; m_name = name; m_boxed = (TypeCodeImpl)boxed; }
/// <summary> /// used for recursive type code creation /// </summary> private void RegisterCreatedTypeCodeForType(Type forType, AttributeExtCollection attributes, TypeCodeImpl typeCode) { TypecodeForTypeKey key = new TypecodeForTypeKey(forType, attributes); lock(m_alreadyCreatedTypeCodes) m_alreadyCreatedTypeCodes[key] = typeCode; }
/// <summary> /// create the type with name fullname, described by forTypeCode! /// </summary> /// <param name="fullname"></param> /// <param name="forTypeCode"></param> /// <returns></returns> internal Type CreateOrGetType(string fullname, TypeCodeImpl forTypeCode) { lock(this) { Type result = RetrieveType(fullname); if (result == null) { result = forTypeCode.CreateType(m_modBuilder, fullname); Repository.RegisterDynamicallyCreatedType(result); } return result; } }
private void SetTypeCode(TypeCode typeCode) { if (!(typeCode is omg.org.CORBA.TypeCodeImpl)) { throw new INTERNAL(567, CompletionStatus.Completed_MayBe); } m_typeCode = (TypeCodeImpl)typeCode; }