Exemple #1
0
        /// <summary>
        /// gets the repository id for a CLS type
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string GetRepositoryID(Type type, bool checkIsPublic)
        {
            // internal types are not supported, because there are a lot of
            // internal types with the same name in ms.net assemblies.
            if (checkIsPublic && !type.IsPublic)
            {
                throw new BAD_PARAM(568, CompletionStatus.Completed_MayBe);
            }

            // can need registration for dynamically created types otherwise RegisterType
            // will simply get it for us
            return(s_instance.RegisterType(type));
        }
Exemple #2
0
 private void RegisterTypes(Assembly forAssembly)
 {
     lock (m_loadedAssemblies.SyncRoot) {
         if (!m_loadedAssemblies.ContainsKey(forAssembly.FullName))
         {
             m_loadedAssemblies[forAssembly.FullName] = forAssembly;
         }
         else
         {
             return; // already loaded
         }
     }
     // locking is done by register type
     Type[] types;
     try {
         types = forAssembly.GetTypes();
     } catch (ReflectionTypeLoadException rtle) { // can happen for dynamic assemblies
         Debug.WriteLine(String.Format("Couldn't load all types from assembly {0}; exception: {1}",
                                       forAssembly.FullName, rtle));
         types = rtle.Types; // the types loaded without exception
     }
     if (types != null)      // check needed for mono, because mono returns null for GetTypes in case of dynamically created assemblies
     {
         for (int i = 0; i < types.Length; i++)
         {
             if (types[i] != null)   // null, if type coudln't be loaded
             {
                 m_forRepository.RegisterType(types[i]);
             }
         }
     }
 }