示例#1
0
        public Task <T> InvokeAsync <T>(ICalleeProxyInterceptor interceptor, MethodInfo method, IOperationResultExtractor <T> extractor, object[] arguments)
        {
            AsyncOperationCallback <T> callback = new AsyncOperationCallback <T>(extractor);

            Task <T> task = InnerInvokeAsync <T>(callback, interceptor, method, arguments);

            return(task);
        }
示例#2
0
        public Task <T> InvokeProgressiveAsync <T>(ICalleeProxyInterceptor interceptor, MethodInfo method, IOperationResultExtractor <T> extractor, object[] arguments, IProgress <T> progress)
        {
            ProgressiveAsyncOperationCallback <T> asyncOperationCallback =
                new ProgressiveAsyncOperationCallback <T>(progress, extractor);

            Task <T> task = InnerInvokeAsync <T>(asyncOperationCallback, interceptor, method, arguments);

            return(task);
        }
示例#3
0
        private Task <T> InnerInvokeAsync <T>(AsyncOperationCallback <T> callback, ICalleeProxyInterceptor interceptor, MethodInfo method, object[] arguments, CancellationToken cancellationToken)
        {
            var cancellableInvocation = Invoke(interceptor, callback, method, arguments);

            // TODO: make the CancelOptions come from the ICalleeProxyInterceptor or something.
            CancellationTokenRegistration registration = cancellationToken.Register(() => cancellableInvocation.Cancel(new CancelOptions()));

            return(AwaitForResult(callback, registration));
        }
        internal WampMetaApiServiceProxy(IWampRealmProxy proxy)
        {
            ICalleeProxyInterceptor calleeProxyInterceptor = CalleeProxyInterceptor.Default;

            mRegistrationDescriptorProxy = new WampRegistrationDescriptorProxyProxy(proxy, calleeProxyInterceptor);
            mSessionDescriptorProxy      = new WampSessionDescriptorProxyProxy(proxy, calleeProxyInterceptor);
            mSubscriptionDescriptor      = new WampSubscriptionDescriptorProxyProxy(proxy, calleeProxyInterceptor);
            SubscribeTo = new MetaEvents(proxy);
        }
示例#5
0
        public T GetProxy <T>(ICalleeProxyInterceptor interceptor) where T : class
        {
            if (typeof(T).IsInterface())
            {
                GenerateCodeAndThrowException <T>();
            }

            return((T)Activator.CreateInstance(typeof(T), mRealmProxy, interceptor));
        }
        protected override IWampCancellableInvocationProxy Invoke(ICalleeProxyInterceptor interceptor, IWampRawRpcOperationClientCallback callback, MethodInfo method, object[] arguments)
        {
            CallOptions callOptions  = interceptor.GetCallOptions(method);
            var         procedureUri = interceptor.GetProcedureUri(method);

            return(mCatalogProxy.Invoke(callback,
                                        callOptions,
                                        procedureUri,
                                        arguments));
        }
        public virtual TProxy GetProxy <TProxy>(ICalleeProxyInterceptor interceptor) where TProxy : class
        {
            TProxy result = DispatchProxy.Create <TProxy, CalleeProxy>();

            CalleeProxy casted = result as CalleeProxy;

            casted.Handler = mHandler;
            casted.CalleeProxyInterceptor = interceptor;

            return(result);
        }
示例#8
0
 public override TProxy GetProxy <TProxy>(ICalleeProxyInterceptor interceptor)
 {
     if (typeof(CalleeProxyBase).IsAssignableFrom(typeof(TProxy)))
     {
         return((TProxy)Activator.CreateInstance(typeof(TProxy), mRealmProxy, interceptor));
     }
     else
     {
         return(base.GetProxy <TProxy>(interceptor));
     }
 }
        public static IInterceptor BuildInterceptor(MethodInfo method, ICalleeProxyInterceptor interceptor, WampCalleeProxyInvocationHandler handler)
        {
            Type interceptorType = GetRelevantInterceptorType(method);

            IInterceptor result =
                (IInterceptor)
                Activator.CreateInstance(interceptorType,
                                         method,
                                         handler,
                                         interceptor);

            return(result);
        }
        private IInterceptor BuildInterceptor(MethodInfo method, ICalleeProxyInterceptor interceptor)
        {
            Type interceptorType =
                GetRelevantInterceptorType(method);

            IInterceptor result =
                (IInterceptor)
                Activator.CreateInstance(interceptorType,
                                         method,
                                         mHandler,
                                         interceptor);

            return(result);
        }
示例#11
0
        private SyncCallback <T> InnerInvokeSync <T>(ICalleeProxyInterceptor interceptor, MethodInfo method, IOperationResultExtractor <T> extractor, object[] arguments, Type unwrapped)
        {
            MethodInfoHelper methodInfoHelper = new MethodInfoHelper(method);

            string procedureUri = interceptor.GetProcedureUri(method);

            SyncCallback <T> syncCallback = new SyncCallback <T>(procedureUri, methodInfoHelper, arguments, extractor);

            object[] argumentsToSend =
                methodInfoHelper.GetInputArguments(arguments);

            Invoke(interceptor, syncCallback, method, argumentsToSend);

            return(syncCallback);
        }
        public virtual TProxy GetProxy <TProxy>(ICalleeProxyInterceptor interceptor) where TProxy : class
        {
            ProxyGenerationOptions options = new ProxyGenerationOptions()
            {
                Selector = new WampCalleeProxyInterceptorSelector()
            };

            IInterceptor[] interceptors =
                typeof(TProxy).GetMethods()
                .Select(method => BuildInterceptor(method, interceptor))
                .ToArray();

            TProxy proxy =
                mGenerator.CreateInterfaceProxyWithoutTarget <TProxy>(options, interceptors);

            return(proxy);
        }
示例#13
0
        public T Invoke <T>(ICalleeProxyInterceptor interceptor, MethodInfo method, IOperationResultExtractor <T> extractor, object[] arguments)
        {
            Type unwrapped = TaskExtensions.UnwrapReturnType(method.ReturnType);

            SyncCallback <T> callback = InnerInvokeSync <T>(interceptor, method, extractor, arguments, unwrapped);

            WaitForResult(callback);

            Exception exception = callback.Exception;

            if (exception != null)
            {
                throw exception;
            }

            return(callback.OperationResult);
        }
        public virtual TProxy GetProxy <TProxy>(ICalleeProxyInterceptor interceptor) where TProxy : class
        {
            if (typeof(CalleeProxyBase).IsAssignableFrom(typeof(TProxy)))
            {
                return((TProxy)Activator.CreateInstance(typeof(TProxy), mProxy, interceptor));
            }
            else
            {
                TProxy result = DispatchProxy.Create <TProxy, CalleeProxy>();

                CalleeProxy casted = result as CalleeProxy;

                casted.Handler = mHandler;
                casted.CalleeProxyInterceptor = interceptor;

                return(result);
            }
        }
示例#15
0
        public virtual TProxy GetProxy <TProxy>(ICalleeProxyInterceptor interceptor) where TProxy : class
        {
            if (typeof(CalleeProxyBase).IsAssignableFrom(typeof(TProxy)))
            {
                return((TProxy)Activator.CreateInstance(typeof(TProxy), mProxy, interceptor));
            }

            try
            {
                TProxy result = DispatchProxy.Create <TProxy, CalleeDispatchProxy>();

                CalleeDispatchProxy casted = result as CalleeDispatchProxy;

                casted.Handler = mHandler;
                casted.CalleeProxyInterceptor = interceptor;

                return(result);
            }
            catch (NotImplementedException)
            {
                Exception exception = CreateExceptionWithGeneratedCode <TProxy>();
                throw exception;
            }
        }
 public WampRegistrationDescriptorProxyProxy
     (IWampRealmProxy realmProxy,
     ICalleeProxyInterceptor interceptor)
     : base(realmProxy, interceptor)
 {
 }
 public ProgressiveAsyncCalleeProxyInterceptor(MethodInfo method, IWampCalleeProxyInvocationHandler handler, ICalleeProxyInterceptor interceptor) : base(method, handler, interceptor)
 {
     SupportsCancellation =
         method.GetParameters().LastOrDefault()?.ParameterType == typeof(CancellationToken);
 }
 public CachedCalleeProxyInterceptor(ICalleeProxyInterceptor underlying)
 {
     mUnderlying = underlying;
 }
 public TProxy GetCalleeProxy <TProxy>(ICalleeProxyInterceptor interceptor) where TProxy : class
 {
     return(mCalleeProxyFactory.GetProxy <TProxy>(interceptor));
 }
示例#20
0
 protected abstract void Invoke(ICalleeProxyInterceptor interceptor, IWampRawRpcOperationClientCallback callback, MethodInfo method, object[] arguments);
 public AsyncCalleeProxyInterceptor(MethodInfo method, IWampCalleeProxyInvocationHandler handler, ICalleeProxyInterceptor interceptor) :
     base(method, handler, interceptor)
 {
 }
示例#22
0
 public WampTestamentServiceProxy
     (IWampRealmProxy realmProxy,
     ICalleeProxyInterceptor interceptor)
     : base(realmProxy, interceptor)
 {
 }
示例#23
0
 public CalleeProxyBase(IWampRealmProxy realmProxy,
                        ICalleeProxyInterceptor interceptor)
 {
     mInterceptor = interceptor;
     mHandler     = new ClientInvocationHandler(realmProxy);
 }
        public static TProxy GetCalleeProxyPortable <TProxy>(this IWampRealmServiceProvider provider, ICalleeProxyInterceptor interceptor) where TProxy : class
        {
#if !PCL
            return(provider.GetCalleeProxy <TProxy>(interceptor));
#else
            try
            {
                return(provider.GetCalleeProxy <TProxy>(interceptor));
            }
            catch (NotSupportedException ex)
            {
                GeneratedCodeException exception =
                    ex.InnerException as GeneratedCodeException;

                var code = exception.GeneratedCode;

                Type instanceType =
                    GetInstanceType <TProxy>(code);

                MethodInfo methodToInvoke =
                    typeof(IWampRealmServiceProvider)
                    .GetMethods()
                    .FirstOrDefault(x => x.Name == "GetCalleeProxy" &&
                                    x.GetParameters().Any());

                TProxy result =
                    methodToInvoke.MakeGenericMethod(instanceType)
                    .Invoke(provider, new object[] { interceptor }) as TProxy;

                return(result);
            }
#endif
        }
示例#25
0
        private Task <T> InnerInvokeAsync <T>(AsyncOperationCallback <T> callback, ICalleeProxyInterceptor interceptor, MethodInfo method, object[] arguments)
        {
            Invoke(interceptor, callback, method, arguments);

            return(AwaitForResult(callback));
        }
 public CalleeProxyInterceptorBase(MethodInfo method, IWampCalleeProxyInvocationHandler handler, ICalleeProxyInterceptor interceptor)
 {
     mMethod      = method;
     mHandler     = handler;
     mInterceptor = interceptor;
 }
 private IInterceptor BuildInterceptor(MethodInfo method, ICalleeProxyInterceptor interceptor)
 {
     return(CalleeProxyInterceptorFactory.BuildInterceptor(method, interceptor, mHandler));
 }
示例#28
0
 public WampSessionManagementServiceProxy
     (IWampRealmProxy realmProxy,
     ICalleeProxyInterceptor interceptor)
     : base(realmProxy, interceptor)
 {
 }