/// <summary>get or create the boxed value type(s) for a .NET arrayType</summary>
 internal Type GetOrCreateBoxedTypeForArray(Type arrayType)
 {
     if (!arrayType.IsArray)
     {
         // an array-type is required for calling GetOrCreateBoxedTypeForArray
         throw new INTERNAL(10050, CompletionStatus.Completed_MayBe);
     }
     lock (this) {
         // for the .NET / .NET case, check if already a boxed type has been created by the idl to cls compiler
         // the repository id, which will identify the boxed value type generated for clsArrayType
         // will be used to check, if this boxed value type has already been created by the idl to cls mapping.
         string repIdForType = (string)m_repIdsForBoxedArrays[arrayType];
         if (repIdForType == null)
         {
             repIdForType = m_boxedValGen.GetRepositoryIDForBoxedArrayType(arrayType);
             m_repIdsForBoxedArrays[arrayType] = repIdForType;
         }
         // repository knows all the types, ask for type for rep-id
         Type result = Repository.GetTypeForId(repIdForType);
         if (result == null)
         {
             // no type found,
             // create the boxed value type(s) for the array
             TypeBuilder resultBuild = m_boxedValGen.CreateBoxedTypeForArray(arrayType, m_modBuilder, this);
             result = resultBuild.CreateType();
             Repository.RegisterDynamicallyCreatedType(result);
         }
         return(result);
     }
 }
예제 #2
0
        /// <summary>
        /// returns true, if interface type iorType is assignable to requiredType.
        /// If not verifable with static inheritance information, returns false.
        /// </summary>
        /// <param name="useTypeForId">returns the best local type to use for iorTypeId</param>
        public static bool IsInterfaceCompatible(Type requiredType, string iorTypeId, out Type useTypeForId)
        {
            Type interfaceType;

            if (iorTypeId.Length != 0)   // empty string stands for CORBA::Object
            {
                interfaceType = Repository.GetTypeForId(iorTypeId);
            }
            else
            {
                interfaceType = ReflectionHelper.MarshalByRefObjectType;
            }
            // for requiredType MarshalByRefObject and omg.org.CORBA.IObject
            // everything is possible (i.e. every remote object type can be assigned to it),
            // the other requiredType types must be checked remote if not locally verifable
            if ((!requiredType.Equals(ReflectionHelper.MarshalByRefObjectType)) &&
                (!requiredType.Equals(ReflectionHelper.IObjectType)) &&
                ((interfaceType == null) || (!IsCompatible(requiredType, interfaceType))))
            {
                // remote type not known or locally assignability not verifable
                useTypeForId = requiredType;
                return(false);
            }
            // interface is assignable (or required type is compatible with all -> do a null check for this case)
            useTypeForId = (interfaceType != null ? interfaceType : requiredType);
            return(true);
        }