public static string GetGUIName(IAssetGenerator generator) { CustomAssetGenerator attr = generator.GetType().GetCustomAttributes(typeof(CustomAssetGenerator), false).FirstOrDefault() as CustomAssetGenerator; return(attr.Name); }
public static bool HasValidAttribute(Type t) { CustomAssetGenerator attr = t.GetCustomAttributes(typeof(CustomAssetGenerator), false).FirstOrDefault() as CustomAssetGenerator; return(attr != null && !string.IsNullOrEmpty(attr.Name)); }
public static string GetVersion(string className) { var type = Type.GetType(className); if (type != null) { CustomAssetGenerator attr = type.GetCustomAttributes(typeof(CustomAssetGenerator), false).FirstOrDefault() as CustomAssetGenerator; if (attr != null) { return(attr.Version); } } return(string.Empty); }
public static Dictionary <string, string> GetAttributeAssemblyQualifiedNameMap() { if (s_attributeAssemblyQualifiedNameMap == null) { // attribute name or class name : class name s_attributeAssemblyQualifiedNameMap = new Dictionary <string, string>(); var allBuilders = new List <Type>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { var builders = assembly.GetTypes() .Where(t => !t.IsInterface) .Where(t => typeof(IAssetGenerator).IsAssignableFrom(t)); allBuilders.AddRange(builders); } foreach (var type in allBuilders) { // set attribute-name as key of dict if atribute is exist. CustomAssetGenerator attr = type.GetCustomAttributes(typeof(CustomAssetGenerator), true).FirstOrDefault() as CustomAssetGenerator; var typename = type.AssemblyQualifiedName; if (attr != null) { if (!s_attributeAssemblyQualifiedNameMap.ContainsKey(attr.Name)) { s_attributeAssemblyQualifiedNameMap[attr.Name] = typename; } } else { s_attributeAssemblyQualifiedNameMap[typename] = typename; } } } return(s_attributeAssemblyQualifiedNameMap); }