Example #1
0
        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);
        }
Example #2
0
 // TODO cache this!
 private MacroOperationAttribute GetAttribute() => MacroOperationAttribute.GetForType(GetType());