Inheritance: BaseMvcContext
 private void ApplyConventions(ActionResultContext context)
 {
     if (this.ViewName == null)
     {
         this.ViewName = context.ActionName;
     }
 }
Exemple #2
0
        public override void Execute(ActionResultContext context, IMonoRailServices services)
        {
            var viewEngines = services.ViewEngines;

            var result = viewEngines.ResolveView(this.View, this.Layout,
                new ViewResolutionContext(context));

            if (result.Successful)
            {
                try
                {
                    result.View.Process(
                        // fix this: params need to come from elsewhere (no statics!)
                        new ViewContext(
                            new HttpContextWrapper(HttpContext.Current), HttpContext.Current.Response.Output),
                        HttpContext.Current.Response.Output);
                }
                finally
                {
                    result.ViewEngine.Release(result.View);
                }
            }
            else
            {
                throw new Exception("Could not find view (or layout?) " + this.View +
                    ". Searched at " + string.Join(", ", result.SearchedLocations));
            }
        }
		public override void Execute(ActionResultContext context, ControllerContext controllerContext, IMonoRailServices services)
		{
			ApplyConventions(context);

			var viewEngines = services.ViewEngines;
			
			var result = viewEngines.ResolveView(this.ViewName, this.Layout, new ViewResolutionContext(context));

			if (result.Successful)
			{
				try
				{
					var httpContext = context.HttpContext;
					var viewContext = new ViewContext(httpContext, httpContext.Response.Output, controllerContext);

					result.View.Process(viewContext, httpContext.Response.Output);
				}
				finally
				{
					result.ViewEngine.Release(result.View);
				}
			}
			else
			{
				throw new Exception("Could not find view " + this.ViewName +
					". Searched at " + string.Join(", ", result.SearchedLocations));
			}
		}
		public override void Execute(ActionResultContext context, ControllerContext controllerContext, IMonoRailServices services)
		{
			var format = services.Serializers.
				Where(f => f.Metadata.MimeTypes.Contains("application/json")).
				Select( f => f.Value ).FirstOrDefault();

			if (format == null)
				throw new NotSupportedException("format not found for json?");

			var data = controllerContext.Data.MainModel;
			// todo: assert isn't null

			format.Serialize(data, context.HttpContext.Response.OutputStream);
			
			context.HttpContext.Response.ContentType = "application/json";
		}
        public override void Execute(ActionResultContext context, IMonoRailServices services)
        {
            var viewEngines = services.ViewEngines;

            var result = viewEngines.ResolveView(_viewName, null, new ViewResolutionContext(context));

            if (result.Successful)
            {
                try
                {
                    result.View.Process(
                        new ViewContext(
                            new HttpContextWrapper(HttpContext.Current), HttpContext.Current.Response.Output),
                        HttpContext.Current.Response.Output);
                }
                finally
                {
                    result.ViewEngine.Release(result.View);
                }
            }
        }
		public abstract void Execute(ActionResultContext context, 
			ControllerContext controllerContext, 
			IMonoRailServices services);
		public override void Execute(ActionResultContext context, ControllerContext controllerContext, IMonoRailServices services)
		{
			context.HttpContext.Response.Write(output);
		}