Example #1
0
 protected CallbackBase(long id, ICallbackExecutor <TMarshal> executor, BindingDelegate <TMarshal> parameterBinder,
                        Type resultType)
 {
     this.id              = id;
     this.executor        = executor;
     this.parameterBinder = parameterBinder;
     this.resultType      = resultType;
 }
        public Delegate Generate(Type delegateType, long id, ICallbackExecutor <TMarshal> callbackExecutor, BindingDelegate <TMarshal> parameterBinder)
        {
            ValidateDelegateType(delegateType);

            if (!typeCache.TryGetValue(delegateType, out var delegateContainerType))
            {
                delegateContainerType = GenerateDelegateContainerType(delegateType);
                typeCache.Add(delegateType, delegateContainerType);
            }

            var created = Activator.CreateInstance(delegateContainerType, id, callbackExecutor, parameterBinder, delegateType);

            return(Delegate.CreateDelegate(delegateType, created, DelegateMethodName, false, true));;
        }
Example #3
0
 public CallbackFactory(ICallbackExecutor <TMarshal> callbackExecutor)
 {
     this.callbackExecutor = callbackExecutor;
 }
Example #4
0
 public TestCallback(long id, ICallbackExecutor <object> executor, BindingDelegate <object> parameterBinder, Type resultType) : base(id, executor, parameterBinder, resultType)
 {
 }
Example #5
0
 private void Sun(ICallbackExecutor <object> callbackExecutor)
 {
     new DelegateContainerBase <object>(1, callbackExecutor, ctx => { }, typeof(object), typeof(Action));
 }
Example #6
0
 public DelegateContainerBase(long id, ICallbackExecutor <TMarshal> executor, BindingDelegate <TMarshal> parameterBinder, Type resultType, Type delegateType)
     : base(id, executor, parameterBinder, resultType)
 {
     bindValues = delegateType.GetMethod(nameof(Action.Invoke)).GetParameters()
                  .Select(p => p.GetCustomAttribute <BindValueAttribute>()).ToArray();
 }
Example #7
0
 public Callback(long id, ICallbackExecutor <TMarshal> executor, BindingDelegate <TMarshal> parameterBinder)
     : base(id, executor, parameterBinder, typeof(object))
 {
 }
Example #8
0
 public void Consume <S, T>(string routeKey, ICallbackExecutor executor)
     where S : IServiceDefinition, new()
 {
     _catalog[typeof(T).FullName] = executor;
     _consumeRoutes.Add <S, T>(routeKey);
 }
Example #9
0
 public void Consume <T>(ICallbackExecutor executor) =>
 _catalog[typeof(T).FullName] = executor;