Beispiel #1
0
        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
            //        });
            //}
        }
Beispiel #2
0
        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);
 }
Beispiel #6
0
 internal abstract void Replace(BasePlugin oldPlugin, BasePlugin newPlugin, Delegate callback, HookOrder order);
Beispiel #7
0
 internal protected abstract void HookBase(BasePlugin plugin, Delegate callback, HookOrder order = HookOrder.NORMAL);
 internal abstract void Replace(BasePlugin oldPlugin, BasePlugin newPlugin, Delegate callback, HookOrder order);
        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);
 public HookAttribute(HookOrder order = HookOrder.NORMAL)
 {
     this.order = order;
 }