Code cleanup.

This commit is contained in:
Chris Ross 2014-08-21 12:13:26 -07:00
parent ddc7f08957
commit bc0732f900
5 changed files with 10 additions and 20 deletions

View File

@ -8,7 +8,7 @@ using System.Globalization;
namespace Microsoft.AspNet.Http namespace Microsoft.AspNet.Http
{ {
/// <summary> /// <summary>
/// Represents the host portion of a Uri can be used to construct Uri's properly formatted and encoded for use in /// Represents the host portion of a URI can be used to construct URI's properly formatted and encoded for use in
/// HTTP headers. /// HTTP headers.
/// </summary> /// </summary>
public struct HostString : IEquatable<HostString> public struct HostString : IEquatable<HostString>
@ -47,7 +47,7 @@ namespace Microsoft.AspNet.Http
/// Any Unicode is converted to punycode. IPv6 addresses will have brackets added if they are missing. /// Any Unicode is converted to punycode. IPv6 addresses will have brackets added if they are missing.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings", Justification = "Only the host segment of a uri is returned.")] [SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings", Justification = "Only the host segment of a URI is returned.")]
public string ToUriComponent() public string ToUriComponent()
{ {
int index; int index;
@ -82,12 +82,12 @@ namespace Microsoft.AspNet.Http
} }
/// <summary> /// <summary>
/// Creates a new HostString from the given uri component. /// Creates a new HostString from the given URI component.
/// Any punycode will be converted to Unicode. /// Any punycode will be converted to Unicode.
/// </summary> /// </summary>
/// <param name="uriComponent"></param> /// <param name="uriComponent"></param>
/// <returns></returns> /// <returns></returns>
[SuppressMessage("Microsoft.Design", "CA1057:StringUriOverloadsCallSystemUriOverloads", Justification = "Only the host segment of a uri is provided.")] [SuppressMessage("Microsoft.Design", "CA1057:StringUriOverloadsCallSystemUriOverloads", Justification = "Only the host segment of a URI is provided.")]
public static HostString FromUriComponent(string uriComponent) public static HostString FromUriComponent(string uriComponent)
{ {
if (!string.IsNullOrEmpty(uriComponent)) if (!string.IsNullOrEmpty(uriComponent))

View File

@ -74,7 +74,7 @@ namespace Microsoft.AspNet.Http
/// </summary> /// </summary>
/// <param name="uriComponent">The escaped path as it appears in the URI format.</param> /// <param name="uriComponent">The escaped path as it appears in the URI format.</param>
/// <returns>The resulting PathString</returns> /// <returns>The resulting PathString</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1057:StringUriOverloadsCallSystemUriOverloads", Justification = "Requirements not compatible with Uri processing")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1057:StringUriOverloadsCallSystemUriOverloads", Justification = "Requirements not compatible with URI processing")]
public static PathString FromUriComponent(string uriComponent) public static PathString FromUriComponent(string uriComponent)
{ {
// REVIEW: what is the exactly correct thing to do? // REVIEW: what is the exactly correct thing to do?

View File

@ -8,7 +8,6 @@ using System.Globalization;
using System.Linq; using System.Linq;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Infrastructure; using Microsoft.AspNet.Http.Infrastructure;
using Microsoft.AspNet.PipelineCore.Collections;
namespace Microsoft.AspNet.PipelineCore.Infrastructure namespace Microsoft.AspNet.PipelineCore.Infrastructure
{ {
@ -507,7 +506,7 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure
} }
} }
internal static partial class ParsingHelpers internal static class ParsingHelpers
{ {
private static readonly Action<string, string, object> AddCookieCallback = (name, value, state) => private static readonly Action<string, string, object> AddCookieCallback = (name, value, state) =>
{ {
@ -592,10 +591,7 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure
scanIndex = delimiterIndex + 1; scanIndex = delimiterIndex + 1;
} }
} }
}
internal static partial class ParsingHelpers
{
public static string GetHeader(IDictionary<string, string[]> headers, string key) public static string GetHeader(IDictionary<string, string[]> headers, string key)
{ {
string[] values = GetHeaderUnmodified(headers, key); string[] values = GetHeaderUnmodified(headers, key);
@ -783,10 +779,7 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure
SetHeaderUnmodified(headers, key, existing.Concat(values)); SetHeaderUnmodified(headers, key, existing.Concat(values));
} }
} }
}
internal static partial class ParsingHelpers
{
private static readonly Action<string, string, object> AppendItemCallback = (name, value, state) => private static readonly Action<string, string, object> AppendItemCallback = (name, value, state) =>
{ {
var dictionary = (IDictionary<string, List<String>>)state; var dictionary = (IDictionary<string, List<String>>)state;
@ -833,10 +826,7 @@ namespace Microsoft.AspNet.PipelineCore.Infrastructure
string[] values; string[] values;
return store.TryGetValue(key, out values) ? values : null; return store.TryGetValue(key, out values) ? values : null;
} }
}
internal static partial class ParsingHelpers
{
//internal static string GetHost(HttpRequest request) //internal static string GetHost(HttpRequest request)
//{ //{
// IHeaderDictionary headers = request.Headers; // IHeaderDictionary headers = request.Headers;

View File

@ -8,7 +8,7 @@ using Microsoft.AspNet.WebUtilities.Collections;
namespace Microsoft.AspNet.WebUtilities namespace Microsoft.AspNet.WebUtilities
{ {
internal static partial class ParsingHelpers internal static class ParsingHelpers
{ {
internal static void ParseDelimited(string text, char[] delimiters, Action<string, string, object> callback, object state) internal static void ParseDelimited(string text, char[] delimiters, Action<string, string, object> callback, object state)
{ {

View File

@ -5,12 +5,12 @@ namespace Microsoft.AspNet.WebUtilities
public static class QueryHelpers public static class QueryHelpers
{ {
/// <summary> /// <summary>
/// Append the given query key and value to the uri. /// Append the given query key and value to the URI.
/// </summary> /// </summary>
/// <param name="uri">The base uri.</param> /// <param name="uri">The base URI.</param>
/// <param name="name">The name of the query key.</param> /// <param name="name">The name of the query key.</param>
/// <param name="value">The query value.</param> /// <param name="value">The query value.</param>
/// <returns>The combine result.</returns> /// <returns>The combined result.</returns>
public static string AddQueryString([NotNull] string uri, [NotNull] string name, [NotNull] string value) public static string AddQueryString([NotNull] string uri, [NotNull] string name, [NotNull] string value)
{ {
bool hasQuery = uri.IndexOf('?') != -1; bool hasQuery = uri.IndexOf('?') != -1;