public HandlerMeta(Type requiredType, Type signalType, int paramCount, EfficientInvoker methodInvoker)
 {
     RequiredType  = requiredType;
     SignalType    = signalType;
     ParamCount    = paramCount;
     MethodInvoker = methodInvoker;
 }
示例#2
0
        public Predicate <object> EntityPredicate = obj => true; // ToDo Support it?

        public HandlerDelegate(Type signalType, EfficientInvoker invoker, object receiver, int args = 2)
        {
            SignalType = signalType;
            Invoker    = invoker;
            Receiver   = receiver;
            Args       = args;
        }
 public HandlerMeta[] GetHandlers(Type type)
 {
     Record("GetHandlers", type);
     Assert.AreEqual(typeof(TestReceiver), type);
     return(new[] {
         new HandlerMeta(typeof(TestEntity), typeof(int), 1,
                         EfficientInvoker.ForMethod(typeof(TestReceiver), "IntReceive")),
         new HandlerMeta(typeof(TestEntity), typeof(char), 2,
                         EfficientInvoker.ForMethod(typeof(TestReceiver), "CharReceive")),
         // Invalid handler, should be ignored
         new HandlerMeta(typeof(string), typeof(char), 2, null)
     });
 }
        public void GlobalStorage()
        {
            var handler = new MockHandlerResolver(new[] {
                new HandlerMeta(null, typeof(int), 2,
                                EfficientInvoker.ForMethod(typeof(TestReceiver), "HandleSignal"))
            });
            var es = new GlobalStorage(handler);

            RunMeasure(() => {
                var receiver = new TestReceiver();
                es.On().Add(receiver);
                es.On().Send(1);
                es.On().Remove(receiver);
            });
        }
        public void DynamicEntityStorage()
        {
            var handler = new MockHandlerResolver(new[] {
                new HandlerMeta(typeof(TestEntity), typeof(int), 2,
                                EfficientInvoker.ForMethod(typeof(TestReceiver), "HandleSignal"))
            });
            var es     = new DynamicStorage(handler);
            var entity = new TestEntity();

            RunMeasure(() => {
                var receiver = new TestReceiver();
                es.On <TestEntity>().Add(receiver);
                es.On(entity).Send(1);
                es.On <TestEntity>().Remove(receiver);
            });
        }
示例#6
0
 public static EfficientInvoker GetInvoker(this Delegate del)
 {
     return(EfficientInvoker.ForDelegate(del));
 }
示例#7
0
 public static EfficientInvoker GetPropertyInvoker(this Type type, string propertyName)
 {
     return(EfficientInvoker.ForProperty(type, propertyName));
 }
示例#8
0
 public static EfficientInvoker GetMethodInvoker(this Type type, string methodName)
 {
     return(EfficientInvoker.ForMethod(type, methodName));
 }
 public static object EfficientInvoke(this ConstructorInfo constructor, params object[] args)
 {
     return(EfficientInvoker.ForConstructor(constructor)(args));
 }