public Library(Configuration.Library libConfig, Assembly assembly) { Name = libConfig.Name; Assembly = assembly; Assembly.GetTypes(); Types = Assembly.GetTypes().Where(type => !libConfig.GetIgnoreType(type)).ToArray(); TypesByName = new TypeTable(Types.Length); TypesByFullName = new TypeTable(Types.Length); foreach (var type in Types) { TypesByName.Add(type.Name, type); TypesByFullName.Add(type.FullName, type); if (type.IsDefined(typeof(TypeAliasAttribute), false)) { var attrs = type.GetCustomAttributes(typeof(TypeAliasAttribute), false); if (attrs.Length > 0 && attrs[0] != null) { var attr = attrs[0] as TypeAliasAttribute; foreach (var alias in attr.Aliases) { TypesByFullName.Add(alias, type); } } } } TypeCache = new TypeCache(Types, TypesByName, TypesByFullName); }
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); }