Пример #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);
        }
Пример #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 );
        }
Пример #3
0
		public TypeCache( Assembly asm )
		{
			if( asm == null )
				m_Types = Type.EmptyTypes;
			else
				m_Types = asm.GetTypes();

			m_Names = new TypeTable( m_Types.Length );
			m_FullNames = new TypeTable( m_Types.Length );

			Type typeofTypeAliasAttribute = typeof( TypeAliasAttribute );

			for( int i = 0; i < m_Types.Length; ++i )
			{
				Type type = m_Types[i];

				m_Names.Add( type.Name, type );
				m_FullNames.Add( type.FullName, type );

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

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

						if( attr != null )
						{
							for( int j = 0; j < attr.Aliases.Length; ++j )
								m_FullNames.Add( attr.Aliases[j], type );
						}
					}
				}
			}
		}
Пример #4
0
 public TypeCache(Type[] types, TypeTable names, TypeTable fullNames)
 {
     m_Types = types;
     m_Names = names;
     m_FullNames = fullNames;
 }
Пример #5
0
 public TypeCache(Type[] types, TypeTable names, TypeTable fullNames)
 {
     m_Types     = types;
     m_Names     = names;
     m_FullNames = fullNames;
 }
Пример #6
0
 public TypeCache(Type[] types, TypeTable names, TypeTable fullNames)
 {
     Types     = types;
     Names     = names;
     FullNames = fullNames;
 }