Exemple #1
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);

            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();
        }