Merge pull request #153 from dtkujawski/dev
Ability to derive Startup from base class
This commit is contained in:
commit
eb2887e5ef
|
|
@ -25,8 +25,8 @@ namespace Microsoft.AspNet.Hosting.Startup
|
||||||
{
|
{
|
||||||
var methodNameWithEnv = string.Format(CultureInfo.InvariantCulture, methodName, environmentName);
|
var methodNameWithEnv = string.Format(CultureInfo.InvariantCulture, methodName, environmentName);
|
||||||
var methodNameWithNoEnv = string.Format(CultureInfo.InvariantCulture, methodName, "");
|
var methodNameWithNoEnv = string.Format(CultureInfo.InvariantCulture, methodName, "");
|
||||||
var methodInfo = startupType.GetTypeInfo().GetDeclaredMethod(methodNameWithEnv)
|
var methodInfo = startupType.GetMethod(methodNameWithEnv, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)
|
||||||
?? startupType.GetTypeInfo().GetDeclaredMethod(methodNameWithNoEnv);
|
?? startupType.GetMethod(methodNameWithNoEnv, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
|
||||||
if (methodInfo == null)
|
if (methodInfo == null)
|
||||||
{
|
{
|
||||||
if (required)
|
if (required)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ using System;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Hosting.Fakes
|
namespace Microsoft.AspNet.Hosting.Fakes
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup : StartupBase
|
||||||
{
|
{
|
||||||
public Startup()
|
public Startup()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using Microsoft.Framework.DependencyInjection;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Hosting.Fakes
|
||||||
|
{
|
||||||
|
public class StartupBase
|
||||||
|
{
|
||||||
|
public void ConfigureBaseClassServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddOptions();
|
||||||
|
services.Configure<FakeOptions>(o =>
|
||||||
|
{
|
||||||
|
o.Configured = true;
|
||||||
|
o.Environment = "BaseClass";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -43,6 +43,7 @@ namespace Microsoft.AspNet.Hosting.Tests
|
||||||
[InlineData("StaticProvider")]
|
[InlineData("StaticProvider")]
|
||||||
[InlineData("Provider")]
|
[InlineData("Provider")]
|
||||||
[InlineData("ProviderArgs")]
|
[InlineData("ProviderArgs")]
|
||||||
|
[InlineData("BaseClass")]
|
||||||
public void StartupClassAddsConfigureServicesToApplicationServices(string environment)
|
public void StartupClassAddsConfigureServicesToApplicationServices(string environment)
|
||||||
{
|
{
|
||||||
var services = HostingServices.Create().BuildServiceProvider();
|
var services = HostingServices.Create().BuildServiceProvider();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue