Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@ -93,14 +93,22 @@ namespace System.Net.Http.Headers
class CollectionHeaderTypeInfo<T, U> : HeaderTypeInfo<T, U> where U : class
{
readonly int minimalCount;
TryParseListDelegate<T> parser;
readonly string separator;
readonly TryParseListDelegate<T> parser;
public CollectionHeaderTypeInfo (string name, TryParseListDelegate<T> parser, HttpHeaderKind headerKind, int minimalCount)
public CollectionHeaderTypeInfo (string name, TryParseListDelegate<T> parser, HttpHeaderKind headerKind, int minimalCount, string separator)
: base (name, null, headerKind)
{
this.parser = parser;
this.minimalCount = minimalCount;
AllowsMany = true;
this.separator = separator;
}
public override string Separator {
get {
return separator;
}
}
public override bool TryParse (string value, out object result)
@ -134,9 +142,9 @@ namespace System.Net.Http.Headers
//
// Headers with #rule for defining lists of elements or *rule for defining occurences of elements
//
public static HeaderInfo CreateMulti<T> (string name, TryParseListDelegate<T> elementParser, HttpHeaderKind headerKind, int minimalCount = 1) where T : class
public static HeaderInfo CreateMulti<T> (string name, TryParseListDelegate<T> elementParser, HttpHeaderKind headerKind, int minimalCount = 1, string separator = ", ") where T : class
{
return new CollectionHeaderTypeInfo<T, T> (name, elementParser, headerKind, minimalCount);
return new CollectionHeaderTypeInfo<T, T> (name, elementParser, headerKind, minimalCount, separator);
}
public object CreateCollection (HttpHeaders headers)
@ -144,6 +152,13 @@ namespace System.Net.Http.Headers
return CreateCollection (headers, this);
}
public virtual string Separator {
get {
// Needed for AllowsMany only
throw new NotSupportedException ();
}
}
public abstract void AddToCollection (object collection, object value);
protected abstract object CreateCollection (HttpHeaders headers, HeaderInfo headerInfo);
public abstract List<string> ToStringCollection (object collection);