Inheritance: RenderingContext
Ejemplo n.º 1
0
        public static MvcRenderingContext GetFromViewContext(ViewContext viewContext)
        {
            object contextObj;
            MvcRenderingContext context = null;

            if (viewContext.ViewData.TryGetValue(ContextKey, out contextObj))
            {
                context = contextObj as MvcRenderingContext;
            }

            return(context);
        }
Ejemplo n.º 2
0
		internal static MvcRenderingContext Build(ViewContext viewContext, IViewDataContainer viewDataContainer, TextWriter writer)
		{
			var context = GetFromViewContext(viewContext);
			if (context != null)
				return context;

			MvcRenderingContext parentContext = null; 
			if (viewContext.ParentActionViewContext != null)
				parentContext = GetFromViewContext(viewContext.ParentActionViewContext);

			context = new MvcRenderingContext(viewContext, viewDataContainer, writer, parentContext);
			viewContext.ViewData.Add(ContextKey, context);

			return context;
		}
Ejemplo n.º 3
0
        internal static MvcRenderingContext Build(ViewContext viewContext, IViewDataContainer viewDataContainer, TextWriter writer)
        {
            var context = GetFromViewContext(viewContext);

            if (context != null)
            {
                return(context);
            }

            MvcRenderingContext parentContext = null;

            if (viewContext.ParentActionViewContext != null)
            {
                parentContext = GetFromViewContext(viewContext.ParentActionViewContext);
            }

            context = new MvcRenderingContext(viewContext, viewDataContainer, writer, parentContext);
            viewContext.ViewData.Add(ContextKey, context);

            return(context);
        }
Ejemplo n.º 4
0
 protected virtual MvcRenderingContext ResolveContext(ViewContext viewContext, IViewDataContainer viewDataContainer, TextWriter writer)
 {
     return(MvcRenderingContext.Build(viewContext, viewDataContainer, writer));
 }