public static Type FindByParkitectObjectByTag(String tag) { IEnumerable <Assembly> scriptAssemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in scriptAssemblies) { foreach (Type type in assembly.GetTypes().Where(T => T.IsClass && T.IsSubclassOf(typeof(ParkitectObj)))) { object[] nodeAttributes = type.GetCustomAttributes(typeof(ParkitectObjectTag), false); if (nodeAttributes.Length <= 0) { continue; } ParkitectObjectTag attr = nodeAttributes[0] as ParkitectObjectTag; if (attr != null) { if (attr.Name.Equals(tag)) { return(type); } } } } return(null); }
public static String GetTagFromParkitectObject(Type type) { object[] nodeAttributes = type.GetCustomAttributes(typeof(ParkitectObjectTag), false); if (nodeAttributes.Length <= 0) { return(null); } ParkitectObjectTag attr = nodeAttributes[0] as ParkitectObjectTag; if (attr != null) { return(attr.Name); } return(null); }