Add() public méthode

public Add ( string key, Type type ) : void
key string
type System.Type
Résultat void
        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);
        }
Exemple #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 );
        }
Exemple #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);
                            }
                        }
                    }
                }
            }
        }
Exemple #4
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);

            foreach (var g in m_Types.ToLookup(t => t.Name))
            {
                m_Names.Add(g.Key, g);

                foreach (var type in g)
                {
                    m_FullNames.Add(type.FullName, type);

                    var attr = type.GetCustomAttribute <TypeAliasAttribute>(false);

                    if (attr != null)
                    {
                        foreach (var a in attr.Aliases)
                        {
                            m_FullNames.Add(a, type);
                        }
                    }
                }
            }

            m_Names.Prune();
            m_FullNames.Prune();

            m_Names.Sort();
            m_FullNames.Sort();
        }
        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);

            var typeofTypeAliasAttribute = typeof(TypeAliasAttribute);

            foreach (var type in m_Types)
            {
                m_Names.Add(type.Name, type);
                m_FullNames.Add(type.FullName, type);

                if (type.IsDefined(typeofTypeAliasAttribute, false))
                {
                    var attrs = type.GetCustomAttributes(typeofTypeAliasAttribute, false);

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

                        if (attr != null)
                        {
                            foreach (var a in attr.Aliases)
                            {
                                m_FullNames.Add(a, type);
                            }
                        }
                    }
                }
            }
        }
Exemple #6
0
        public TypeCache(Assembly asm)
        {
            if (asm == null)
            {
                Types = Type.EmptyTypes;
            }
            else
            {
                Types = asm.GetTypes();
            }

            Names     = new TypeTable(Types.Length);
            FullNames = new TypeTable(Types.Length);

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

                Names.Add(type.Name, type);
                FullNames.Add(type.FullName, type);
            }
        }
        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);

            foreach (IGrouping <string, Type> g in m_Types.ToLookup(t => t.Name))
            {
                m_Names.Add(g.Key, g);

                foreach (Type type in g)
                {
                    m_FullNames.Add(type.FullName, type);

                    TypeAliasAttribute attr = type.GetCustomAttribute <TypeAliasAttribute>(false);

                    if (attr != null)
                    {
                        for (var index = 0; index < attr.Aliases.Length; index++)
                        {
                            string a = attr.Aliases[index];

                            m_FullNames.Add(a, type);
                        }
                    }
                }
            }

            m_Names.Sort();
            m_FullNames.Sort();
        }
Exemple #8
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 );
						}
					}
				}
			}
		}