Quick cleanup

- `DefaultInlineConstraintResolver` has no need of a `IServiceProvider`

nits:
- add doc comments for changed `DefaultInlineConstraintResolver` ctor
- let VS add a dev server port to sample's .kproj
- add debugSettings.json and .vs/ to .gitignore
This commit is contained in:
Doug Bunting 2015-01-30 10:02:58 -08:00
parent e1ff9ae259
commit c59366e8a7
9 changed files with 18 additions and 17 deletions

2
.gitignore vendored
View File

@ -7,6 +7,8 @@ _ReSharper.*/
packages/ packages/
artifacts/ artifacts/
PublishProfiles/ PublishProfiles/
.vs/
debugSettings.json
*.user *.user
*.suo *.suo
*.cache *.cache

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
@ -12,6 +12,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<DevelopmentServerPort>25397</DevelopmentServerPort>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" /> <Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project> </Project>

View File

@ -18,12 +18,15 @@ namespace Microsoft.AspNet.Routing
public class DefaultInlineConstraintResolver : IInlineConstraintResolver public class DefaultInlineConstraintResolver : IInlineConstraintResolver
{ {
private readonly IDictionary<string, Type> _inlineConstraintMap; private readonly IDictionary<string, Type> _inlineConstraintMap;
private readonly IServiceProvider _serviceProvider;
public DefaultInlineConstraintResolver(IServiceProvider serviceProvider, /// <summary>
IOptions<RouteOptions> routeOptions) /// Initializes a new instance of the <see cref="DefaultInlineConstraintResolver"/> class.
/// </summary>
/// <param name="routeOptions">
/// Accessor for <see cref="RouteOptions"/> containing the constraints of interest.
/// </param>
public DefaultInlineConstraintResolver(IOptions<RouteOptions> routeOptions)
{ {
_serviceProvider = serviceProvider;
_inlineConstraintMap = routeOptions.Options.ConstraintMap; _inlineConstraintMap = routeOptions.Options.ConstraintMap;
} }

View File

@ -302,10 +302,7 @@ namespace Microsoft.AspNet.Routing.Tests
{ {
var optionsAccessor = new Mock<IOptions<RouteOptions>>(); var optionsAccessor = new Mock<IOptions<RouteOptions>>();
optionsAccessor.SetupGet(o => o.Options).Returns(routeOptions); optionsAccessor.SetupGet(o => o.Options).Returns(routeOptions);
var serviceProvider = new Mock<IServiceProvider>(); return new DefaultInlineConstraintResolver(optionsAccessor.Object);
serviceProvider.Setup(o => o.GetService(It.Is<Type>(type => type == typeof(ITypeActivator))))
.Returns(new TypeActivator());
return new DefaultInlineConstraintResolver(serviceProvider.Object, optionsAccessor.Object);
} }
private class MultiConstructorRouteConstraint : IRouteConstraint private class MultiConstructorRouteConstraint : IRouteConstraint

View File

@ -300,7 +300,7 @@ namespace Microsoft.AspNet.Routing.Tests
.Add("test", typeof(TestRouteConstraint))); .Add("test", typeof(TestRouteConstraint)));
var serviceProvider = services.BuildServiceProvider(); var serviceProvider = services.BuildServiceProvider();
var accessor = serviceProvider.GetRequiredService<IOptions<RouteOptions>>(); var accessor = serviceProvider.GetRequiredService<IOptions<RouteOptions>>();
return new DefaultInlineConstraintResolver(serviceProvider, accessor); return new DefaultInlineConstraintResolver(accessor);
} }
private class TestRouteConstraint : IRouteConstraint private class TestRouteConstraint : IRouteConstraint

View File

@ -179,14 +179,12 @@ namespace Microsoft.AspNet.Routing
private static RouteConstraintBuilder CreateBuilder(string template) private static RouteConstraintBuilder CreateBuilder(string template)
{ {
var services = new Mock<IServiceProvider>(MockBehavior.Strict);
var options = new Mock<IOptions<RouteOptions>>(MockBehavior.Strict); var options = new Mock<IOptions<RouteOptions>>(MockBehavior.Strict);
options options
.SetupGet(o => o.Options) .SetupGet(o => o.Options)
.Returns(new RouteOptions()); .Returns(new RouteOptions());
var inlineConstraintResolver = new DefaultInlineConstraintResolver(services.Object, options.Object); var inlineConstraintResolver = new DefaultInlineConstraintResolver(options.Object);
return new RouteConstraintBuilder(inlineConstraintResolver, template); return new RouteConstraintBuilder(inlineConstraintResolver, template);
} }
} }

View File

@ -1182,7 +1182,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
var services = new ServiceCollection().AddOptions(); var services = new ServiceCollection().AddOptions();
var serviceProvider = services.BuildServiceProvider(); var serviceProvider = services.BuildServiceProvider();
var accessor = serviceProvider.GetRequiredService<IOptions<RouteOptions>>(); var accessor = serviceProvider.GetRequiredService<IOptions<RouteOptions>>();
return new DefaultInlineConstraintResolver(serviceProvider, accessor); return new DefaultInlineConstraintResolver(accessor);
} }
private class PathAndQuery private class PathAndQuery

View File

@ -929,7 +929,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
var services = new ServiceCollection().AddOptions(); var services = new ServiceCollection().AddOptions();
var serviceProvider = services.BuildServiceProvider(); var serviceProvider = services.BuildServiceProvider();
var accessor = serviceProvider.GetRequiredService<IOptions<RouteOptions>>(); var accessor = serviceProvider.GetRequiredService<IOptions<RouteOptions>>();
return new DefaultInlineConstraintResolver(serviceProvider, accessor); return new DefaultInlineConstraintResolver(accessor);
} }
} }
} }

View File

@ -108,7 +108,7 @@ namespace Microsoft.AspNet.Routing.Tests
var services = new ServiceCollection().AddOptions(); var services = new ServiceCollection().AddOptions();
var serviceProvider = services.BuildServiceProvider(); var serviceProvider = services.BuildServiceProvider();
var accessor = serviceProvider.GetRequiredService<IOptions<RouteOptions>>(); var accessor = serviceProvider.GetRequiredService<IOptions<RouteOptions>>();
return new DefaultInlineConstraintResolver(serviceProvider, accessor); return new DefaultInlineConstraintResolver(accessor);
} }
} }
} }