Пример #1
0
        public async Task <object> InvokeInterfaceAsync(ClientRequestMessage clientMessage)
        {
            var invokeInfos = InterfaceCollection.GetInvokeInformation(clientMessage.Method);

            var authentication = new SignalARRRAuthentication(_serviceProvider);
            var result         = await authentication.Authorize(ClientContext, clientMessage.Authorization, invokeInfos.MethodInfo);

            if (!result.Succeeded)
            {
                throw new UnauthorizedException();
            }

            object instance;

            if (invokeInfos.MethodInfo.DeclaringType == HARRR.GetType())
            {
                instance = ActivatorUtilities.CreateInstance(_serviceProvider, HARRR.GetType());
            }
            else
            {
                instance = invokeInfos.Factory.DynamicInvoke(_serviceProvider);
            }



            return(await InvokeMethodInfoAsync(instance, invokeInfos.MethodInfo, clientMessage.Arguments, clientMessage.GenericArguments));
        }
Пример #2
0
        public async Task <IAsyncEnumerable <object> > InvokeInterfaceStreamAsync(ClientRequestMessage clientMessage, CancellationToken cancellationToken)
        {
            var invokeInfos = InterfaceCollection.GetInvokeInformation(clientMessage.Method);

            var authentication = new SignalARRRAuthentication(_serviceProvider);
            var result         = await authentication.Authorize(ClientContext, clientMessage.Authorization, invokeInfos.MethodInfo);

            if (!result.Succeeded)
            {
                throw new UnauthorizedException();
            }

            var instance = invokeInfos.Factory.DynamicInvoke(_serviceProvider);


            return(await InvokeStreamMethodInfoAsync(instance, invokeInfos.MethodInfo, clientMessage.Arguments,
                                                     cancellationToken));
        }