Beispiel #1
0
        public Library(Config.Library libConfig, Assembly _assembly)
        {
            name = libConfig.Name;
            assembly = _assembly;

            ArrayList typeList = new ArrayList();
            assembly.GetTypes();
            foreach (Type type in assembly.GetTypes()) {
                if (libConfig == null || !libConfig.GetIgnoreType(type))
                    typeList.Add(type);
            }
            types = (Type[])typeList.ToArray(typeof(Type));

            typesByName = new TypeTable(types.Length);
            typesByFullName = new TypeTable(types.Length);

            Type typeofTypeAliasAttribute = typeof(TypeAliasAttribute);

            foreach (Type type in types) {
                typesByName.Add(type.Name, type);
                typesByFullName.Add(type.FullName, type);

                if (type.IsDefined(typeofTypeAliasAttribute, false)) {
                    object[] attrs = type.GetCustomAttributes(typeofTypeAliasAttribute, false);

                    if (attrs != null && attrs.Length > 0 && attrs[0] != null) {
                        TypeAliasAttribute attr = attrs[0] as TypeAliasAttribute;
                        foreach (string alias in attr.Aliases)
                            typesByFullName.Add(alias, type);
                    }
                }
            }

            typeCache = new TypeCache(types, typesByName, typesByFullName);
        }
Beispiel #2
0
        public Library( Configuration.Library libConfig, Assembly assembly )
        {
            m_Name = libConfig.Name;
            m_Assembly = assembly;

            m_Assembly.GetTypes();

            List<Type> typeList = new List<Type>();

            foreach ( Type type in m_Assembly.GetTypes() )
            {
                if ( libConfig == null || !libConfig.GetIgnoreType( type ) )
                    typeList.Add( type );
            }

            m_Types = typeList.ToArray();

            m_TypesByName = new TypeTable( m_Types.Length );
            m_TypesByFullName = new TypeTable( m_Types.Length );

            foreach ( Type type in m_Types )
            {
                m_TypesByName.Add( type.Name, type );
                m_TypesByFullName.Add( type.FullName, type );

                if ( type.IsDefined( typeof( TypeAliasAttribute ), false ) )
                {
                    object[] attrs = type.GetCustomAttributes( typeof( TypeAliasAttribute ), false );

                    if ( attrs != null && attrs.Length > 0 && attrs[0] != null )
                    {
                        TypeAliasAttribute attr = attrs[0] as TypeAliasAttribute;

                        foreach ( string alias in attr.Aliases )
                            m_TypesByFullName.Add( alias, type );
                    }
                }
            }

            m_TypeCache = new TypeCache( m_Types, m_TypesByName, m_TypesByFullName );
        }
Beispiel #3
0
		public static TypeCache GetTypeCache( Assembly asm )
		{
			if( asm == null )
			{
				if( m_NullCache == null )
					m_NullCache = new TypeCache( null );

				return m_NullCache;
			}

			TypeCache c = null;
			m_TypeCaches.TryGetValue( asm, out c );

			if( c == null )
				m_TypeCaches[asm] = c = new TypeCache( asm );

			return c;
		}
        public static TypeCache GetTypeCache( Assembly asm )
        {
            if ( asm == null )
            {
                if ( m_NullCache == null )
                    m_NullCache = new TypeCache(Type.EmptyTypes,
                                                new TypeTable(0),
                                                new TypeTable(0));

                return m_NullCache;
            }

            TypeCache c = (TypeCache)m_TypeCaches[asm];

            if (c == null) {
                Library l = findLibrary(asm);
                if (l == null)
                    throw new ApplicationException("Invalid assembly");
                m_TypeCaches[asm] = c = l.TypeCache;
            }

            return c;
        }
Beispiel #5
0
        public static TypeCache GetTypeCache( Assembly assembly )
        {
            if ( assembly == null )
            {
                if ( m_NullCache == null )
                    m_NullCache = new TypeCache( Type.EmptyTypes, new TypeTable( 0 ), new TypeTable( 0 ) );

                return m_NullCache;
            }

            TypeCache cache = (TypeCache) m_TypeCaches[assembly];

            if ( cache == null )
            {
                Library library = FindLibrary( assembly );

                if ( library == null )
                    throw new ApplicationException( "Invalid assembly" );

                m_TypeCaches[assembly] = cache = library.TypeCache;
            }

            return cache;
        }
		public static TypeCache GetTypeCache(Assembly asm)
		{
			if (asm == null)
			{
				if (m_NullCache == null)
					m_NullCache = new TypeCache(null);

				return m_NullCache;
			}

			TypeCache c = (TypeCache)m_TypeCaches[asm];

			if (c == null)
				m_TypeCaches[asm] = c = new TypeCache(asm);

			return c;
		}