Code review cleanup.

This commit is contained in:
Chris Ross 2014-03-20 11:21:03 -07:00
parent 9e8032cc8a
commit eb27892470
6 changed files with 13 additions and 18 deletions

View File

@ -13,12 +13,6 @@ namespace Microsoft.AspNet.Server.WebListener
{ {
internal static class LogHelper internal static class LogHelper
{ {
private static readonly Func<object, Exception, string> LogState =
(state, error) => Convert.ToString(state, CultureInfo.CurrentCulture);
private static readonly Func<object, Exception, string> LogStateAndError =
(state, error) => string.Format(CultureInfo.CurrentCulture, "{0}\r\n{1}", state, error);
internal static ILogger CreateLogger(ILoggerFactory factory, Type type) internal static ILogger CreateLogger(ILoggerFactory factory, Type type)
{ {
if (factory == null) if (factory == null)

View File

@ -47,10 +47,10 @@ namespace Microsoft.AspNet.Server.WebListener
/// </summary> /// </summary>
/// <param name="properties"></param> /// <param name="properties"></param>
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Disposed by caller")] [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Disposed by caller")]
public IServerInformation Initialize(IConfiguration config) public IServerInformation Initialize(IConfiguration configuration)
{ {
OwinWebListener listener = new OwinWebListener(); OwinWebListener listener = new OwinWebListener();
ParseAddresses(config, listener); ParseAddresses(configuration, listener);
return new WebListenerWrapper(listener, _loggerFactory); return new WebListenerWrapper(listener, _loggerFactory);
} }

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Reflection;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Abstractions; using Microsoft.AspNet.Abstractions;
@ -44,7 +45,7 @@ namespace Microsoft.AspNet.Server.WebListener
// Microsoft.AspNet.Server.WebListener // Microsoft.AspNet.Server.WebListener
public string Name public string Name
{ {
get { return System.Reflection.IntrospectionExtensions.GetTypeInfo(GetType()).Assembly.GetName().Name; } get { return GetType().GetTypeInfo().Assembly.GetName().Name; }
} }
internal void Start(AppFunc app) internal void Start(AppFunc app)

View File

@ -1,16 +1,16 @@
/* TODO: Take a temp dependency on Ms.Aspnet.Hosting until AssemblyNeutral gets fixed. /* TODO: Take a temp dependency on Ms.Aspnet.Hosting until AssemblyNeutral gets fixed.
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Net.Runtime; using Microsoft.AspNet.Abstractions;
using Microsoft.AspNet.ConfigurationModel;
namespace Microsoft.AspNet.Hosting.Server namespace Microsoft.AspNet.Hosting.Server
{ {
[AssemblyNeutral] // TODO: [AssemblyNeutral]
public interface IServerFactory public interface IServerFactory
{ {
// IServerConfiguration CreateConfiguration(); IServerInformation Initialize(IConfiguration configuration);
// IDisposable Start(IServerConfiguration serverConfig, Func<object, Task> app); IDisposable Start(IServerInformation serverInformation, Func<object, Task> application);
IDisposable Start(Func<object, Task> app);
} }
} }
*/ */

View File

@ -150,8 +150,8 @@ namespace Microsoft.AspNet.Server.WebListener.Test
private IDisposable CreateServer(AppFunc app) private IDisposable CreateServer(AppFunc app)
{ {
ServerFactory factory = new ServerFactory(null); var factory = new ServerFactory(null);
WebListenerWrapper wrapper = (WebListenerWrapper)factory.Initialize(null); var wrapper = (WebListenerWrapper)factory.Initialize(null);
foreach (string path in new[] { "/", "/11", "/2/3", "/2", "/11/2" }) foreach (string path in new[] { "/", "/11", "/2/3", "/2", "/11/2" })
{ {

View File

@ -191,8 +191,8 @@ namespace Microsoft.AspNet.Server.WebListener.Test
[Fact] [Fact]
public async Task Server_SetQueueLimit_Success() public async Task Server_SetQueueLimit_Success()
{ {
ServerFactory factory = new ServerFactory(null); var factory = new ServerFactory(null);
WebListenerWrapper wrapper = (WebListenerWrapper)factory.Initialize(null); var wrapper = (WebListenerWrapper)factory.Initialize(null);
wrapper.Listener.UriPrefixes.Add(Prefix.Create("http://localhost:8080")); wrapper.Listener.UriPrefixes.Add(Prefix.Create("http://localhost:8080"));
wrapper.Listener.SetRequestQueueLimit(1001); wrapper.Listener.SetRequestQueueLimit(1001);