Review cleanup. Cleaner Startup auto-detect. Fix tests.

This commit is contained in:
Chris Ross 2014-03-13 14:25:30 -07:00
parent ee4bb6de87
commit 6a5cb913c8
5 changed files with 14 additions and 10 deletions

View File

@ -48,10 +48,8 @@ namespace Microsoft.AspNet.Hosting
using (engine.Start(context))
{
#if NET45
Console.WriteLine("Started");
Console.ReadLine();
#endif
}
}
}

View File

@ -38,16 +38,21 @@ namespace Microsoft.AspNet.Hosting.Startup
Type type = null;
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)
{
type = typeInfo.AsType();
}
}
else
{
type = assembly.GetType(typeName);
}
if (type == null)
{

View File

@ -12,6 +12,7 @@
"k10": {
"dependencies": {
"System.Collections": "4.0.0.0",
"System.Console": "4.0.0.0",
"System.ComponentModel": "4.0.0.0",
"System.Diagnostics.Debug": "4.0.10.0",
"System.IO": "4.0.0.0",

View File

@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Hosting
var context = new HostingContext
{
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);

View File

@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Hosting
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.NotNull(startup);
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Hosting
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);