public void HookBase(HookPoint hookPoint, HookOrder order, NLua.LuaFunction callback) { var targetType = hookPoint.DelegateType.GetGenericArguments()[0]; var call = this.GetType().GetMethod("InternalCall");//.MakeGenericMethod(targetType); var act = typeof(HookAction <>).MakeGenericType(targetType); var inst = Activator.CreateInstance(act, call); //if (initialized) //hookPoint.HookBase(this, new HookAction<Object>((ref HookContext ctx, ref Object args) => //{ // callback.Call(ctx, args); //})); //else //{ // lock (desiredHooks) // desiredHooks.Add(new HookEntry // { // hookPoint = hookPoint, // callback = new HookAction<Object>((ref HookContext ctx, ref Object args) => // { // callback.Call(ctx, args); // }), // order = order // }); //} }
internal protected void HookBase(Delegate callback, HookOrder order = HookOrder.NORMAL) { var plugin = callback.Target as BasePlugin; if (plugin == null) { throw new ArgumentException("Callback doesn't point to an instance method of class BasePlugin", "callback"); } HookBase(plugin, callback, order); }
public void HookBase(HookPoint hookPoint, HookOrder order, Delegate callback) { if (initialized) { hookPoint.HookBase(this, callback); } else { lock (desiredHooks) desiredHooks.Add(new HookEntry { hookPoint = hookPoint, callback = callback, order = order }); } }
public HookAttribute(HookOrder order = HookOrder.NORMAL) { this.order = order; }
public void Hook <T>(HookPoint <T> hookPoint, HookOrder order, HookAction <T> callback) { HookBase(hookPoint, order, callback); }
internal abstract void Replace(BasePlugin oldPlugin, BasePlugin newPlugin, Delegate callback, HookOrder order);
internal protected abstract void HookBase(BasePlugin plugin, Delegate callback, HookOrder order = HookOrder.NORMAL);
protected internal void HookBase(Delegate callback, HookOrder order = HookOrder.NORMAL) { var plugin = callback.Target as BasePlugin; if (plugin == null) throw new ArgumentException ("Callback doesn't point to an instance method of class BasePlugin", "callback"); HookBase (plugin, callback, order); }
protected internal abstract void HookBase(BasePlugin plugin, Delegate callback, HookOrder order = HookOrder.NORMAL);