Пример #1
0
        protected async Task <DataWithStateCode> GenericHandle <T, TResult>(TRequest header, RequestContext <TRequest> context, CancellationToken token) where T : IOperation <TResult>
        {
            var segArray = header.OperationData.To();
            var arg      = context.OperationDescription.UseAsyncSerialize
                ? await _serializer.DeserializeAsync <T>(segArray, context.Session)
                : _serializer.Deserialize <T>(segArray, context.Session);

            var typedHandler = _factory.Create <T, TResult, TRequest>(context);
            var result       = await typedHandler.Handle(arg, context, token);

            if (context.HandlerDescription.LifeTime == Scope.Request)
            {
                _factory.Destroy(typedHandler);
            }

            if (!context.OperationDescription.WaitResponse)
            {
                return(default);