Review feedback. Style cleanup. Updated build template files.
This commit is contained in:
parent
a3eb280275
commit
ee4bb6de87
|
|
@ -20,3 +20,5 @@ nuget.exe
|
|||
*.userprefs
|
||||
*DS_Store
|
||||
*.ncrunchsolution
|
||||
*.*sdf
|
||||
*.ipch
|
||||
18
Hosting.sln
18
Hosting.sln
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.21005.1
|
||||
VisualStudioVersion = 12.0.30203.2
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E0497F39-AFFB-4819-A116-E39E361915AB}"
|
||||
EndProject
|
||||
|
|
@ -13,6 +13,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Hosting.k1
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Hosting.Tests.net45", "test\Microsoft.AspNet.Hosting.Tests\Microsoft.AspNet.Hosting.Tests.net45.csproj", "{80588AF3-6B14-4D11-9DC4-1EF6453B54C9}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{C30C98CD-3D69-4AE9-B680-0E0E6D8834C6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KWebStartup.net45", "samples\KWebStartup\KWebStartup.net45.csproj", "{E9B21845-E51A-4B8C-AF0B-0C4CE16550BF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KWebStartup.k10", "samples\KWebStartup\KWebStartup.k10.csproj", "{348007AA-AB91-48B2-98DB-57D068E2C1AE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -31,6 +37,14 @@ Global
|
|||
{80588AF3-6B14-4D11-9DC4-1EF6453B54C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{80588AF3-6B14-4D11-9DC4-1EF6453B54C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{80588AF3-6B14-4D11-9DC4-1EF6453B54C9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E9B21845-E51A-4B8C-AF0B-0C4CE16550BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E9B21845-E51A-4B8C-AF0B-0C4CE16550BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E9B21845-E51A-4B8C-AF0B-0C4CE16550BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E9B21845-E51A-4B8C-AF0B-0C4CE16550BF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{348007AA-AB91-48B2-98DB-57D068E2C1AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{348007AA-AB91-48B2-98DB-57D068E2C1AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{348007AA-AB91-48B2-98DB-57D068E2C1AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{348007AA-AB91-48B2-98DB-57D068E2C1AE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -39,5 +53,7 @@ Global
|
|||
{D546290B-E280-4D99-BA9C-0D364A0AFB54} = {E0497F39-AFFB-4819-A116-E39E361915AB}
|
||||
{DBB72F0F-755D-41CF-8FE2-F4B6AE214E91} = {E0497F39-AFFB-4819-A116-E39E361915AB}
|
||||
{80588AF3-6B14-4D11-9DC4-1EF6453B54C9} = {FEB39027-9158-4DE2-997F-7ADAEF8188D0}
|
||||
{E9B21845-E51A-4B8C-AF0B-0C4CE16550BF} = {C30C98CD-3D69-4AE9-B680-0E0E6D8834C6}
|
||||
{348007AA-AB91-48B2-98DB-57D068E2C1AE} = {C30C98CD-3D69-4AE9-B680-0E0E6D8834C6}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2/" />
|
||||
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2" />
|
||||
<add key="NuGet.org" value="https://nuget.org/api/v2/" />
|
||||
</packageSources>
|
||||
<packageSourceCredentials>
|
||||
|
|
|
|||
12
build.cmd
12
build.cmd
|
|
@ -1,10 +1,18 @@
|
|||
@echo off
|
||||
cd %~dp0
|
||||
|
||||
IF EXIST .nuget\NuGet.exe goto restore
|
||||
SETLOCAL
|
||||
SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe
|
||||
|
||||
IF EXIST %CACHED_NUGET% goto copynuget
|
||||
echo Downloading latest version of NuGet.exe...
|
||||
IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet
|
||||
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'"
|
||||
|
||||
:copynuget
|
||||
IF EXIST .nuget\nuget.exe goto restore
|
||||
md .nuget
|
||||
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '.nuget\NuGet.exe'"
|
||||
copy %CACHED_NUGET% .nuget\nuget.exe > nul
|
||||
|
||||
:restore
|
||||
IF EXIST packages\KoreBuild goto run
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
using Microsoft.AspNet.Abstractions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KWebStartup
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"version": "0.1-alpha-*",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Abstractions": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.Hosting": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.Server.WebListener": "0.1-alpha-*"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNet.Abstractions;
|
||||
using Microsoft.AspNet.DependencyInjection;
|
||||
using Microsoft.AspNet.Hosting.Builder;
|
||||
using Microsoft.AspNet.Hosting.Startup;
|
||||
using Microsoft.AspNet.Hosting.Server;
|
||||
using Microsoft.AspNet.Hosting.Startup;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting
|
||||
{
|
||||
|
|
@ -55,7 +54,10 @@ namespace Microsoft.AspNet.Hosting
|
|||
|
||||
private void EnsureServerFactory(HostingContext context)
|
||||
{
|
||||
context.ServerFactory = context.ServerFactory ?? context.Services.GetService<IServerFactory>();
|
||||
if (context.ServerFactory == null)
|
||||
{
|
||||
context.ServerFactory = context.Services.GetService<IServerFactory>();
|
||||
}
|
||||
if (context.ServerFactory != null)
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ using System.Collections.Generic;
|
|||
using Microsoft.AspNet.ConfigurationModel;
|
||||
using Microsoft.AspNet.DependencyInjection;
|
||||
using Microsoft.AspNet.Hosting.Builder;
|
||||
using Microsoft.AspNet.Hosting.Startup;
|
||||
using Microsoft.AspNet.Hosting.Server;
|
||||
using Microsoft.AspNet.Hosting.Startup;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
using Microsoft.AspNet.ConfigurationModel;
|
||||
using Microsoft.AspNet.ConfigurationModel.Sources;
|
||||
using Microsoft.AspNet.DependencyInjection;
|
||||
using Microsoft.AspNet.Hosting.Server;
|
||||
using Microsoft.Net.Runtime;
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.ConfigurationModel;
|
||||
using Microsoft.AspNet.DependencyInjection;
|
||||
using Microsoft.Net.Runtime;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using Microsoft.AspNet.DependencyInjection;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.DependencyInjection;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting.Server
|
||||
{
|
||||
|
|
@ -16,28 +16,14 @@ namespace Microsoft.AspNet.Hosting.Server
|
|||
|
||||
public IServerFactory GetServerFactory(string serverFactoryIdentifier)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(serverFactoryIdentifier))
|
||||
if (string.IsNullOrEmpty(serverFactoryIdentifier))
|
||||
{
|
||||
throw new ArgumentNullException("serverFactoryIdentifier");
|
||||
throw new ArgumentException(string.Empty, "serverFactoryIdentifier");
|
||||
}
|
||||
|
||||
string typeName;
|
||||
string assemblyName;
|
||||
var parts = serverFactoryIdentifier.Split(new[] { ',' }, 2);
|
||||
if (parts.Length == 1)
|
||||
{
|
||||
typeName = null;
|
||||
assemblyName = serverFactoryIdentifier;
|
||||
}
|
||||
else if (parts.Length == 2)
|
||||
{
|
||||
typeName = parts[0];
|
||||
assemblyName = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("TODO: Unrecognized format", "serverFactoryIdentifier");
|
||||
}
|
||||
var nameParts = Utilities.SplitTypeName(serverFactoryIdentifier);
|
||||
string typeName = nameParts.Item1;
|
||||
string assemblyName = nameParts.Item2;
|
||||
|
||||
var assembly = Assembly.Load(new AssemblyName(assemblyName));
|
||||
if (assembly == null)
|
||||
|
|
@ -47,12 +33,11 @@ namespace Microsoft.AspNet.Hosting.Server
|
|||
|
||||
Type type = null;
|
||||
Type interfaceInfo;
|
||||
if (string.IsNullOrWhiteSpace(typeName))
|
||||
if (string.IsNullOrEmpty(typeName))
|
||||
{
|
||||
foreach (var typeInfo in assembly.DefinedTypes)
|
||||
{
|
||||
interfaceInfo = typeInfo.ImplementedInterfaces.FirstOrDefault(interf =>
|
||||
interf.FullName == typeof(IServerFactory).FullName);
|
||||
interfaceInfo = typeInfo.ImplementedInterfaces.FirstOrDefault(interf => interf.Equals(typeof(IServerFactory)));
|
||||
if (interfaceInfo != null)
|
||||
{
|
||||
type = typeInfo.AsType();
|
||||
|
|
@ -66,15 +51,14 @@ namespace Microsoft.AspNet.Hosting.Server
|
|||
}
|
||||
else
|
||||
{
|
||||
type = assembly.GetType(typeName) ?? assembly.GetType(assemblyName + "." + typeName);
|
||||
type = assembly.GetType(typeName);
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
throw new Exception(String.Format("TODO: type {0} failed to load message", typeName ?? "<null>"));
|
||||
}
|
||||
|
||||
interfaceInfo = type.GetTypeInfo().ImplementedInterfaces.FirstOrDefault(interf =>
|
||||
interf.FullName == typeof(IServerFactory).FullName);
|
||||
interfaceInfo = type.GetTypeInfo().ImplementedInterfaces.FirstOrDefault(interf => interf.Equals(typeof(IServerFactory)));
|
||||
|
||||
if (interfaceInfo == null)
|
||||
{
|
||||
|
|
@ -82,8 +66,7 @@ namespace Microsoft.AspNet.Hosting.Server
|
|||
}
|
||||
}
|
||||
|
||||
object instance = ActivatorUtilities.GetServiceOrCreateInstance(_services, type);
|
||||
return (IServerFactory)instance;
|
||||
return (IServerFactory)ActivatorUtilities.GetServiceOrCreateInstance(_services, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,23 +25,9 @@ namespace Microsoft.AspNet.Hosting.Startup
|
|||
return _next.LoadStartup(applicationName, diagnosticMessages);
|
||||
}
|
||||
|
||||
string typeName;
|
||||
string assemblyName;
|
||||
var parts = applicationName.Split(new[] { ',' }, 2);
|
||||
if (parts.Length == 1)
|
||||
{
|
||||
typeName = null;
|
||||
assemblyName = applicationName;
|
||||
}
|
||||
else if (parts.Length == 2)
|
||||
{
|
||||
typeName = parts[0];
|
||||
assemblyName = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("TODO: Unrecognized format");
|
||||
}
|
||||
var nameParts = Utilities.SplitTypeName(applicationName);
|
||||
string typeName = nameParts.Item1;
|
||||
string assemblyName = nameParts.Item2;
|
||||
|
||||
var assembly = Assembly.Load(new AssemblyName(assemblyName));
|
||||
if (assembly == null)
|
||||
|
|
@ -50,7 +36,7 @@ namespace Microsoft.AspNet.Hosting.Startup
|
|||
}
|
||||
|
||||
Type type = null;
|
||||
if (string.IsNullOrWhiteSpace(typeName))
|
||||
if (string.IsNullOrEmpty(typeName))
|
||||
{
|
||||
var typeInfo = assembly.DefinedTypes.FirstOrDefault(aType => aType.Name.Equals("Startup"));
|
||||
if (typeInfo != null)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting
|
||||
{
|
||||
internal static class Utilities
|
||||
{
|
||||
internal static Tuple<string, string> SplitTypeName(string identifier)
|
||||
{
|
||||
string typeName;
|
||||
string assemblyName;
|
||||
var parts = identifier.Split(new[] { ',' }, 2);
|
||||
if (parts.Length == 1)
|
||||
{
|
||||
typeName = null;
|
||||
assemblyName = identifier.Trim();
|
||||
}
|
||||
else if (parts.Length == 2)
|
||||
{
|
||||
typeName = parts[0].Trim();
|
||||
assemblyName = parts[1].Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("TODO: Unrecognized format", "identifier");
|
||||
}
|
||||
return new Tuple<string, string>(typeName, assemblyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using Microsoft.AspNet.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting.Tests.Fakes
|
||||
namespace Microsoft.AspNet.Hosting.Fakes
|
||||
{
|
||||
public class FakeStartup
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using Microsoft.AspNet.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting.Tests.Fakes
|
||||
namespace Microsoft.AspNet.Hosting.Fakes
|
||||
{
|
||||
public class FakeStartupWithServices
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.AspNet.Hosting.Tests.Fakes
|
||||
namespace Microsoft.AspNet.Hosting.Fakes
|
||||
{
|
||||
public interface IFakeStartupCallback
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Abstractions;
|
||||
using Microsoft.AspNet.DependencyInjection;
|
||||
using Microsoft.AspNet.Hosting.Server;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting.Tests
|
||||
namespace Microsoft.AspNet.Hosting
|
||||
{
|
||||
public class HostingEngineTests : IServerFactory
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Abstractions;
|
||||
using Microsoft.AspNet.DependencyInjection;
|
||||
using Microsoft.AspNet.Hosting.Startup;
|
||||
using Microsoft.AspNet.Hosting.Tests.Fakes;
|
||||
using Microsoft.AspNet.Hosting.Fakes;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting.Tests
|
||||
namespace Microsoft.AspNet.Hosting
|
||||
{
|
||||
|
||||
public class StartupManagerTests : IFakeStartupCallback
|
||||
|
|
|
|||
Loading…
Reference in New Issue