private static IReadOnlyDictionary <MacroOperationType, Type> FindAllTypes() { var result = new Dictionary <MacroOperationType, Type>(); var assembly = typeof(MacroOperationAttribute).GetTypeInfo().Assembly; foreach (Type type in assembly.GetTypes()) { if (!typeof(MacroOpBase).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) { continue; } MacroOperationAttribute attribute = type.GetTypeInfo().GetCustomAttributes <MacroOperationAttribute>().FirstOrDefault(); if (attribute == null) { continue; } result.Add(attribute.Operation, type); } return(result); }
// TODO cache this! private MacroOperationAttribute GetAttribute() => MacroOperationAttribute.GetForType(GetType());