Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
* Code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbrandenburg committed Oct 15, 2015
1 parent 875d9ae commit a4f1507
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/ViewContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

using System;
using System.IO;
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.ViewEngines;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Microsoft.Extensions.DependencyInjection;

namespace Microsoft.AspNet.Mvc.Rendering
{
Expand Down Expand Up @@ -68,15 +68,17 @@ public ViewContext(
{
throw new ArgumentNullException(nameof(htmlHelperOptions));
}
var service = actionContext.HttpContext.RequestServices;

if (viewData == null)
{
viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
var modelMetadataProvider = service.GetRequiredService<IModelMetadataProvider>();
viewData = new ViewDataDictionary(modelMetadataProvider);
}

if (tempData == null)
{
tempData = new TempDataDictionary(new HttpContextAccessor(), new SessionStateTempDataProvider());
tempData = service.GetRequiredService<ITempDataDictionary>();
}

View = view;
Expand Down Expand Up @@ -117,7 +119,8 @@ public ViewContext(

if (viewData == null)
{
viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
var metadata = viewContext.HttpContext.RequestServices.GetRequiredService<IModelMetadataProvider>();
viewData = new ViewDataDictionary(metadata);
}

if (writer == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
using System.Diagnostics.Tracing;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.Infrastructure;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Mvc.ViewEngines;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.OptionsModel;
using Microsoft.Net.Http.Headers;

Expand Down Expand Up @@ -121,14 +121,16 @@ public virtual async Task ExecuteAsync(
throw new ArgumentNullException(nameof(view));
}

var services = actionContext.HttpContext.RequestServices;
if (viewData == null)
{
viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
var metadataProvider = services.GetRequiredService<IModelMetadataProvider>();
viewData = new ViewDataDictionary(metadataProvider);
}

if (tempData == null)
{
tempData = new TempDataDictionary(new HttpContextAccessor(), new SessionStateTempDataProvider());
tempData = services.GetRequiredService<ITempDataDictionary>();
}

var response = actionContext.HttpContext.Response;
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.AspNet.Mvc.ViewFeatures/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"Microsoft.AspNet.Antiforgery": "1.0.0-*",
"Microsoft.AspNet.Diagnostics.Abstractions": "1.0.0-*",
"Microsoft.AspNet.Html.Abstractions": "1.0.0-*",
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Mvc.Core": "6.0.0-*",
"Microsoft.AspNet.Mvc.DataAnnotations": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Json": "6.0.0-*",
Expand Down

0 comments on commit a4f1507

Please sign in to comment.