CR feedback
This commit is contained in:
parent
ab605ef935
commit
e740633c06
|
|
@ -1,8 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.Contracts;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.DependencyInjection;
|
using Microsoft.AspNet.DependencyInjection;
|
||||||
|
|
@ -15,6 +17,8 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
private readonly HashSet<string> _renderedSections = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
private readonly HashSet<string> _renderedSections = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
private bool _renderedBody;
|
private bool _renderedBody;
|
||||||
|
|
||||||
|
public IViewComponentHelper Component { get; private set; }
|
||||||
|
|
||||||
public ViewContext Context { get; set; }
|
public ViewContext Context { get; set; }
|
||||||
|
|
||||||
public string Layout { get; set; }
|
public string Layout { get; set; }
|
||||||
|
|
@ -42,7 +46,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
SectionWriters = new Dictionary<string, HelperResult>(StringComparer.OrdinalIgnoreCase);
|
SectionWriters = new Dictionary<string, HelperResult>(StringComparer.OrdinalIgnoreCase);
|
||||||
Context = context;
|
Context = context;
|
||||||
|
|
||||||
Url = context.ServiceProvider.GetService<IUrlHelper>();
|
InitHelpers();
|
||||||
|
|
||||||
var contentBuilder = new StringBuilder(1024);
|
var contentBuilder = new StringBuilder(1024);
|
||||||
using (var bodyWriter = new StringWriter(contentBuilder))
|
using (var bodyWriter = new StringWriter(contentBuilder))
|
||||||
|
|
@ -78,6 +82,21 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitHelpers()
|
||||||
|
{
|
||||||
|
Contract.Assert(Context != null);
|
||||||
|
|
||||||
|
Url = Context.ServiceProvider.GetService<IUrlHelper>();
|
||||||
|
|
||||||
|
Component = Context.ServiceProvider.GetService<IViewComponentHelper>();
|
||||||
|
|
||||||
|
var contextable = Component as ICanHasViewContext;
|
||||||
|
if (contextable != null)
|
||||||
|
{
|
||||||
|
contextable.Contextualize(Context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task RenderLayoutAsync(ViewContext context, string bodyContent)
|
private async Task RenderLayoutAsync(ViewContext context, string bodyContent)
|
||||||
{
|
{
|
||||||
var virtualPathFactory = context.ServiceProvider.GetService<IVirtualPathViewFactory>();
|
var virtualPathFactory = context.ServiceProvider.GetService<IVirtualPathViewFactory>();
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
|
|
||||||
public ViewDataDictionary<TModel> ViewData { get; private set; }
|
public ViewDataDictionary<TModel> ViewData { get; private set; }
|
||||||
|
|
||||||
public IViewComponentHelper Component { get; private set; }
|
|
||||||
|
|
||||||
public IHtmlHelper<TModel> Html { get; set; }
|
public IHtmlHelper<TModel> Html { get; set; }
|
||||||
|
|
||||||
public override Task RenderAsync([NotNull] ViewContext context)
|
public override Task RenderAsync([NotNull] ViewContext context)
|
||||||
|
|
@ -55,14 +53,6 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
{
|
{
|
||||||
contextable.Contextualize(context);
|
contextable.Contextualize(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Component = context.ServiceProvider.GetService<IViewComponentHelper>();
|
|
||||||
|
|
||||||
contextable = Component as ICanHasViewContext;
|
|
||||||
if (contextable != null)
|
|
||||||
{
|
|
||||||
contextable.Contextualize(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue