internal static IEnumerable<MacroInfo> GetMacros(Type type, Symbol @namespace, IMessageSink sink, object instance = null)
{
var flags = BindingFlags.Public | BindingFlags.Static;
if (instance != null)
flags |= BindingFlags.Instance;
foreach(var method in type.GetMethods(flags)) {
foreach (LexicalMacroAttribute attr in method.GetCustomAttributes(typeof(LexicalMacroAttribute), false)) {
var @delegate = AsDelegate(method, sink, instance);
if (@delegate != null)
yield return new MacroInfo(@namespace, attr, @delegate);
}
}
}
static LexicalMacro AsDelegate(MethodInfo method, IMessageSink sink, object instance)