public ListenerObject(MethodInfo info, ListenerOptions options, string modId = null) { Info = info; Func = Info.GetMethodInvoker(); var attrib = info.GetFirstAttribute <EventAttribute>(); if (string.IsNullOrEmpty(modId)) { ModId = Utility.ActiveModId; } else { ModId = modId; } if (string.IsNullOrWhiteSpace(options.DebugName)) { options.DebugName = "[" + Path.GetFileName(info.Module.Assembly.Location) + "] " + info.DeclaringType.FullName + "." + info.Name; } options.PriorityStore = options.PriorityStore ?? attrib?.Priority ?? 0; options.ContinueOnCancel = options.ContinueOnCancel || (attrib?.ContinueOnCancel ?? false); options.ContinueOnThrow = options.ContinueOnThrow || (attrib?.ContinueOnThrow ?? false); Options = options; }
public static void RegisterListener(Type pathfinderEventType, Action <PathfinderEvent> listener, ListenerOptions options) { InternalUtility.ValidateNoId(log: false); RegisterExpressionListener(pathfinderEventType, new ListenerObject(listener.Method, options)); }
public static void RegisterListener <T>(Action <T> listener, ListenerOptions options) where T : PathfinderEvent { InternalUtility.ValidateNoId(log: false); RegisterExpressionListener(typeof(T), new ListenerObject(listener.Method, options)); }