/Web/QValueParsing.cs |
@@ -1,18 +1,18 @@ |
// The MIT License (MIT) |
// |
// |
// Copyright (c) 2015 Dave Transom |
// |
// |
// Permission is hereby granted, free of charge, to any person obtaining a |
// copy of this software and associated documentation files (the |
// copy of this software and associated documentation files (the |
// "Software"), to deal in the Software without restriction, including |
// without limitation the rights to use, copy, modify, merge, publish, |
// distribute, sublicense, and/or sell copies of the Software, and to |
// permit persons to whom the Software is furnished to do so, subject to |
// the following conditions: |
// |
// |
// The above copyright notice and this permission notice shall be included |
// in all copies or substantial portions of the Software. |
// |
// |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
@@ -48,7 +48,7 @@ |
[DebuggerDisplay("QValue[{Name}, {Weight}]")] |
public struct QValue : IComparable<QValue> |
{ |
private static readonly char[] delimiters = {';', '='}; |
private static readonly char[] delimiters = { ';', '=' }; |
private const float defaultWeight = 1; |
|
#region Fields |
@@ -56,7 +56,7 @@ |
private float _weight; |
private int _ordinal; |
|
#endregion |
#endregion Fields |
|
#region Constructors |
|
@@ -89,7 +89,7 @@ |
ParseInternal(ref this, value); |
} |
|
#endregion |
#endregion Constructors |
|
#region Properties |
|
@@ -114,7 +114,7 @@ |
/// </summary> |
public bool IsEmpty => string.IsNullOrEmpty(Name); |
|
#endregion |
#endregion Properties |
|
#region Methods |
|
@@ -165,7 +165,7 @@ |
} |
} |
|
#endregion |
#endregion Methods |
|
#region IComparable<QValue> Members |
|
@@ -186,7 +186,7 @@ |
return value; |
} |
|
#endregion |
#endregion IComparable<QValue> Members |
|
#region CompareByWeight |
|
@@ -212,7 +212,7 @@ |
return -x.CompareTo(y); |
} |
|
#endregion |
#endregion CompareByWeight |
} |
|
/// <summary> |
@@ -225,7 +225,7 @@ |
[DebuggerDisplay("QValue[{Count}, {AcceptWildcard}]")] |
public sealed class QValueList : List<QValue> |
{ |
private static readonly char[] delimiters = {','}; |
private static readonly char[] delimiters = { ',' }; |
|
#region Add |
|
@@ -241,7 +241,7 @@ |
applyAutoSort(); |
} |
|
#endregion |
#endregion Add |
|
#region AddRange |
|
@@ -261,7 +261,7 @@ |
applyAutoSort(); |
} |
|
#endregion |
#endregion AddRange |
|
#region Find |
|
@@ -277,7 +277,7 @@ |
return Find(criteria); |
} |
|
#endregion |
#endregion Find |
|
#region FindHighestWeight |
|
@@ -297,7 +297,7 @@ |
return Find(criteria); |
} |
|
#endregion |
#endregion FindHighestWeight |
|
#region FindPreferred |
|
@@ -318,7 +318,7 @@ |
return Find(criteria); |
} |
|
#endregion |
#endregion FindPreferred |
|
#region DefaultSort |
|
@@ -331,7 +331,7 @@ |
Sort(QValue.CompareByWeightDesc); |
} |
|
#endregion |
#endregion DefaultSort |
|
#region applyAutoSort |
|
@@ -345,7 +345,7 @@ |
DefaultSort(); |
} |
|
#endregion |
#endregion applyAutoSort |
|
#region isCandidate |
|
@@ -366,12 +366,8 @@ |
return false; |
} |
|
#endregion |
#endregion isCandidate |
|
#region Fields |
|
#endregion |
|
#region Constructors |
|
/// <summary> |
@@ -413,7 +409,7 @@ |
AutoSort = true; |
} |
|
#endregion |
#endregion Constructors |
|
#region Properties |
|
@@ -434,6 +430,6 @@ |
/// <returns>An QValue based on weight, or null</returns> |
public QValue this[params string[] candidates] => FindPreferred(candidates); |
|
#endregion |
#endregion Properties |
} |
} |
} |
/Web/Utilities/WebExtensions.cs |
@@ -16,15 +16,15 @@ |
{ |
private static readonly Func<string, string> directURIEscapeDataString = |
((Expression<Func<string, string>>) |
(data => string.Join("", Enumerable.Range(0, (data.Length + 32765)/32766).AsParallel() |
.Select(o => Uri.EscapeDataString(data.Substring(o*32766, Math.Min(32766, data.Length - o*32766)))) |
(data => string.Join("", Enumerable.Range(0, (data.Length + 32765) / 32766).AsParallel() |
.Select(o => Uri.EscapeDataString(data.Substring(o * 32766, Math.Min(32766, data.Length - o * 32766)))) |
.ToArray()))).Compile(); |
|
private static readonly Func<string, string> directURIUnescapeDataString = |
((Expression<Func<string, string>>) |
(data => string.Join("", Enumerable.Range(0, (data.Length + 32765)/32766).AsParallel() |
(data => string.Join("", Enumerable.Range(0, (data.Length + 32765) / 32766).AsParallel() |
.Select( |
o => Uri.UnescapeDataString(data.Substring(o*32766, Math.Min(32766, data.Length - o*32766)))) |
o => Uri.UnescapeDataString(data.Substring(o * 32766, Math.Min(32766, data.Length - o * 32766)))) |
.ToArray()))).Compile(); |
|
/////////////////////////////////////////////////////////////////////////// |
@@ -91,4 +91,4 @@ |
return split.Length <= 1 || !long.TryParse(split[1], out port) ? 80 : port; |
} |
} |
} |
} |