/// <summary>
        /// Builds method delegates
        /// </summary>
        protected virtual void SetupMethod()
        {
            lock (this)
            {
                if (ActivationFunc == null)
                {
                    AssignActivationFunc();

                    BindParametersDelegate =
                        Services.ParameterBinderDelegateBuilder.CreateParameterBindingMethod(Configuration, out var parametersType);

                    if (Configuration.InvokeInformation.MethodInvokeDelegate == null)
                    {
                        InvokeMethodDelegate =
                            Services.MethodInvokerCreationService.BuildMethodInvoker <TReturn>(Configuration, parametersType);
                    }
                    else
                    {
                        InvokeMethodDelegate =
                            (InvokeMethodDelegate <TReturn>)(object) Configuration.InvokeInformation.MethodInvokeDelegate;
                    }

                    ResponseDelegate = Services.ResponseDelegateCreator.CreateResponseDelegate(Configuration);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="contentSerializer"></param>
        /// <param name="rawContentWriter"></param>
        /// <param name="configurationManager"></param>
        /// <param name="compressionPredicateProvider"></param>
        public ResponseDelegateCreator(IContentSerializationService contentSerializer,
                                       IRawContentWriter rawContentWriter,
                                       IConfigurationManager configurationManager,
                                       ICompressionActionProvider compressionPredicateProvider)
        {
            ContentSerializer            = contentSerializer;
            RawContentWriter             = rawContentWriter;
            ConfigurationManager         = configurationManager;
            CompressionPredicateProvider = compressionPredicateProvider;

            DefaultContentSerializer = contentSerializer.SerializeToResponse;
        }
Example #3
0
        private static async Task AwaitInvoke(RequestExecutionContext requestContext,
                                              Task <TReturn> executionResult,
                                              IErrorHandler servicesErrorHandler,
                                              MethodEndPointDelegate responseDelegate)
        {
            try
            {
                requestContext.Result = await executionResult;

                if (!requestContext.ResponseHasStarted)
                {
                    await responseDelegate(requestContext);
                }
            }
            catch (Exception e)
            {
                await servicesErrorHandler.HandleException(requestContext, e);
            }
        }