Review cleanup. Cleaner Startup auto-detect. Fix tests.
This commit is contained in:
parent
ee4bb6de87
commit
6a5cb913c8
|
|
@ -48,10 +48,8 @@ namespace Microsoft.AspNet.Hosting
|
||||||
|
|
||||||
using (engine.Start(context))
|
using (engine.Start(context))
|
||||||
{
|
{
|
||||||
#if NET45
|
|
||||||
Console.WriteLine("Started");
|
Console.WriteLine("Started");
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,16 +38,21 @@ namespace Microsoft.AspNet.Hosting.Startup
|
||||||
Type type = null;
|
Type type = null;
|
||||||
if (string.IsNullOrEmpty(typeName))
|
if (string.IsNullOrEmpty(typeName))
|
||||||
{
|
{
|
||||||
var typeInfo = assembly.DefinedTypes.FirstOrDefault(aType => aType.Name.Equals("Startup"));
|
typeName = "Startup";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the most likely places first
|
||||||
|
type = assembly.GetType(typeName) ?? assembly.GetType(assembly + "." + typeName);
|
||||||
|
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
// Full scan
|
||||||
|
var typeInfo = assembly.DefinedTypes.FirstOrDefault(aType => aType.Name.Equals(typeName));
|
||||||
if (typeInfo != null)
|
if (typeInfo != null)
|
||||||
{
|
{
|
||||||
type = typeInfo.AsType();
|
type = typeInfo.AsType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
type = assembly.GetType(typeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"k10": {
|
"k10": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"System.Collections": "4.0.0.0",
|
"System.Collections": "4.0.0.0",
|
||||||
|
"System.Console": "4.0.0.0",
|
||||||
"System.ComponentModel": "4.0.0.0",
|
"System.ComponentModel": "4.0.0.0",
|
||||||
"System.Diagnostics.Debug": "4.0.10.0",
|
"System.Diagnostics.Debug": "4.0.10.0",
|
||||||
"System.IO": "4.0.0.0",
|
"System.IO": "4.0.0.0",
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Hosting
|
||||||
var context = new HostingContext
|
var context = new HostingContext
|
||||||
{
|
{
|
||||||
ServerFactory = this,
|
ServerFactory = this,
|
||||||
ApplicationName = "Microsoft.AspNet.Hosting.Tests.Fakes.FakeStartup, Microsoft.AspNet.Hosting.Tests"
|
ApplicationName = "Microsoft.AspNet.Hosting.Fakes.FakeStartup, Microsoft.AspNet.Hosting.Tests"
|
||||||
};
|
};
|
||||||
|
|
||||||
var engineStart = engine.Start(context);
|
var engineStart = engine.Start(context);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Hosting
|
||||||
|
|
||||||
var manager = services.GetService<IStartupManager>();
|
var manager = services.GetService<IStartupManager>();
|
||||||
|
|
||||||
var startup = manager.LoadStartup("Microsoft.AspNet.Hosting.Tests.Fakes.FakeStartup, Microsoft.AspNet.Hosting.Tests");
|
var startup = manager.LoadStartup("Microsoft.AspNet.Hosting.Fakes.FakeStartup, Microsoft.AspNet.Hosting.Tests");
|
||||||
|
|
||||||
Assert.IsType<StartupManager>(manager);
|
Assert.IsType<StartupManager>(manager);
|
||||||
Assert.NotNull(startup);
|
Assert.NotNull(startup);
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Hosting
|
||||||
|
|
||||||
var manager = services.GetService<IStartupManager>();
|
var manager = services.GetService<IStartupManager>();
|
||||||
|
|
||||||
var startup = manager.LoadStartup("Microsoft.AspNet.Hosting.Tests.Fakes.FakeStartupWithServices, Microsoft.AspNet.Hosting.Tests");
|
var startup = manager.LoadStartup("Microsoft.AspNet.Hosting.Fakes.FakeStartupWithServices, Microsoft.AspNet.Hosting.Tests");
|
||||||
|
|
||||||
startup.Invoke(null);
|
startup.Invoke(null);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue