Exemple #1
0
 public IActionResult CreateActionResult(Type declaredReturnType, object actionReturnValue, RequestContext requestContext)
 {
     return new ContentResult
     {
         ContentType = "text/plain",
         Content = Convert.ToString(actionReturnValue),
     };
 }
 public ControllerActionInvoker(RequestContext requestContext,
                                ControllerBasedActionDescriptor descriptor, 
                                IActionResultFactory actionResultFactory, 
                                IServiceProvider serviceProvider)
 {
     _requestContext = requestContext;
     _descriptor = descriptor;
     _actionResultFactory = actionResultFactory;
     _serviceProvider = serviceProvider;
 }
Exemple #3
0
        public Task ExecuteAsync(IOwinContext context, IRouteData routeData)
        {
            var requestContext = new RequestContext(context, routeData);

            IActionInvokerFactory invokerFactory = _serviceProvider.GetService<IActionInvokerFactory>();

            var invoker = invokerFactory.CreateInvoker(requestContext);

            return invoker.InvokeActionAsync();
        }
Exemple #4
0
        public HtmlHelper(RequestContext requestContext, ViewData viewData)
        {
            if (requestContext == null)
            {
                throw new ArgumentNullException("requestContext");
            }

            RequestContext = requestContext;
            ViewData = viewData;
            // ClientValidationRuleFactory = (name, metadata) => ModelValidatorProviders.Providers.GetValidators(metadata ?? ModelMetadata.FromStringExpression(name, ViewData), ViewContext).SelectMany(v => v.GetClientValidationRules());
        }
Exemple #5
0
        private async Task<IView> FindView(RequestContext requestContext, string viewName)
        {
            ViewEngineResult result = await _viewEngine.FindView(requestContext, viewName);
            if (!result.Success)
            {
                string locationsText = String.Join(Environment.NewLine, result.SearchedLocations);
                const string message = @"The view &apos;{0}&apos; was not found. The following locations were searched:{1}.";
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, message, viewName, locationsText));
            }

            return result.View;
        }
Exemple #6
0
        public async Task ExecuteResultAsync(RequestContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            IOwinResponse response = context.HttpContext.Response;

            response.StatusCode = (int)HttpStatusCode.NoContent;

            await Task.FromResult(false);

            return;
        }
        public IActionInvoker GetInvoker(RequestContext requestContext, ActionDescriptor descriptor)
        {
            var controllerActionDescriptor = descriptor as ControllerBasedActionDescriptor;

            if (controllerActionDescriptor != null)
            {
                return new ControllerActionInvoker(
                    requestContext,
                    controllerActionDescriptor,
                    _actionResultFactory,
                    _serviceProvider);
            }

            return null;
        }
Exemple #8
0
        public async Task ExecuteResultAsync(RequestContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            IView view = await FindView(context, ViewName);
            using (view as IDisposable)
            {
                context.HttpContext.Response.ContentType = "text/html";
                using (var writer = new StreamWriter(context.HttpContext.Response.Body, Encoding.UTF8, 1024, leaveOpen: true))
                {
                    var viewContext = new ViewContext(context.HttpContext, context.RouteData, ViewData)
                    {
                        ServiceProvider = _serviceProvider
                    };
                    await view.RenderAsync(viewContext, writer);
                }
            }
        }
Exemple #9
0
        public async Task ExecuteResultAsync(RequestContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            IOwinResponse response = context.HttpContext.Response;

            if (!String.IsNullOrEmpty(ContentType))
            {
                response.ContentType = ContentType;
            }

            //if (ContentEncoding != null)
            //{
            //    response.ContentEncoding = ContentEncoding;
            //}

            if (Content != null)
            {
                await response.WriteAsync(Content);
            }
        }
Exemple #10
0
 public async Task ExecuteResultAsync(RequestContext context)
 {
     context.HttpContext.Response.StatusCode = _statusCode;
 }
Exemple #11
0
        public IActionInvoker CreateInvoker(RequestContext requestContext)
        {
            ActionDescriptor descriptor = _actionDescriptorProvider.CreateDescriptor(requestContext);

            return _actionInvokerProvider.GetInvoker(requestContext, descriptor);
        }
Exemple #12
0
        public IActionInvoker CreateInvoker(RequestContext requestContext)
        {
            ActionDescriptor descriptor = _actionDescriptorProvider.CreateDescriptor(requestContext);

            return _actionInvokerProvider.GetInvoker(requestContext, descriptor);
        }
Exemple #13
0
 public async Task ExecuteResultAsync(RequestContext context)
 {
 }