Code review cleanup.

This commit is contained in:
Chris Ross 2014-02-10 10:52:19 -08:00
parent 40a7181ff0
commit fe1011e507
3 changed files with 25 additions and 9 deletions

View File

@ -169,7 +169,7 @@ namespace Microsoft.AspNet.PipelineCore.Owin
object obj; object obj;
if (Environment.TryGetValue(OwinConstants.SendFiles.SendAsync, out obj)) if (Environment.TryGetValue(OwinConstants.SendFiles.SendAsync, out obj))
{ {
SendFileFunc func = (SendFileFunc)obj; var func = (SendFileFunc)obj;
return func(path, offset, length, cancellation); return func(path, offset, length, cancellation);
} }
throw new NotSupportedException(OwinConstants.SendFiles.SendAsync); throw new NotSupportedException(OwinConstants.SendFiles.SendAsync);
@ -237,7 +237,7 @@ namespace Microsoft.AspNet.PipelineCore.Owin
{ {
get get
{ {
IList<Type> keys = new List<Type>() var keys = new List<Type>()
{ {
typeof(IHttpRequestInformation), typeof(IHttpRequestInformation),
typeof(IHttpResponseInformation), typeof(IHttpResponseInformation),
@ -306,12 +306,30 @@ namespace Microsoft.AspNet.PipelineCore.Owin
public bool Contains(KeyValuePair<Type, object> item) public bool Contains(KeyValuePair<Type, object> item)
{ {
throw new NotImplementedException(); object result;
return TryGetValue(item.Key, out result) && result.Equals(item.Value);
} }
public void CopyTo(KeyValuePair<Type, object>[] array, int arrayIndex) public void CopyTo(KeyValuePair<Type, object>[] array, int arrayIndex)
{ {
throw new NotImplementedException(); if (array == null)
{
throw new ArgumentNullException("array");
}
if (arrayIndex < 0 || arrayIndex > array.Length)
{
throw new ArgumentOutOfRangeException("arrayIndex", arrayIndex, string.Empty);
}
var keys = Keys;
if (keys.Count > array.Length - arrayIndex)
{
throw new ArgumentException();
}
foreach (var key in keys)
{
array[arrayIndex++] = new KeyValuePair<Type, object>(key, this[key]);
}
} }
public int Count public int Count

View File

@ -132,8 +132,8 @@ namespace Microsoft.AspNet.PipelineCore
{ {
get get
{ {
// TODO: Which feature exposes this?
return CancellationToken.None; return CancellationToken.None;
// throw new NotImplementedException();
} }
set set
{ {

View File

@ -51,11 +51,9 @@ namespace Microsoft.AspNet.PipelineCore
{ {
get get
{ {
string[] values;
long value; long value;
if (HttpResponseInformation.Headers.TryGetValue(Constants.Headers.ContentLength, out values) string rawValue = Headers.Get(Constants.Headers.ContentLength);
&& values != null && values.Length > 0 && !string.IsNullOrWhiteSpace(values[0]) if (!string.IsNullOrWhiteSpace(rawValue) && long.TryParse(rawValue, out value))
&& long.TryParse(values[0], out value))
{ {
return value; return value;
} }