11using System . Collections . Specialized ;
22using System . Diagnostics . Contracts ;
33using System . Net . Http . Formatting . Internal ;
4+ using System . Web . Http ;
45
56namespace System . Net . Http . Headers
67{
78 public class CookieState : ICloneable
89 {
910 private string _name ;
10- private NameValueCollection _values ;
11+ private NameValueCollection _values = HttpValueCollection . Create ( ) ;
1112
1213 public CookieState ( string name )
1314 : this ( name , String . Empty )
@@ -30,7 +31,7 @@ public CookieState(string name, NameValueCollection values)
3031
3132 if ( values == null )
3233 {
33- throw new ArgumentNullException ( "values" ) ;
34+ throw Error . ArgumentNull ( "values" ) ;
3435 }
3536 Values . Add ( values ) ;
3637 }
@@ -57,8 +58,8 @@ public string Name
5758 }
5859
5960 /// <summary>
60- /// If the cookie data is a simple string value then set or retrieve it using the <see cref="M: Value"/> property.
61- /// If the cookie data is structured then use the <see cref="M: Values"/> property.
61+ /// If the cookie data is a simple string value then set or retrieve it using the <see cref="Value"/> property.
62+ /// If the cookie data is structured then use the <see cref="Values"/> property.
6263 /// </summary>
6364 public string Value
6465 {
@@ -82,19 +83,12 @@ public string Value
8283 }
8384
8485 /// <summary>
85- /// If the cookie data is structured then use the <see cref="M: Values"/> property for setting and getting individual values.
86- /// If the cookie data is a simple string value then set or retrieve it using the <see cref="M: Value"/> property.
86+ /// If the cookie data is structured then use the <see cref="Values"/> property for setting and getting individual values.
87+ /// If the cookie data is a simple string value then set or retrieve it using the <see cref="Value"/> property.
8788 /// </summary>
8889 public NameValueCollection Values
8990 {
90- get
91- {
92- if ( _values == null )
93- {
94- _values = HttpValueCollection . Create ( ) ;
95- }
96- return _values ;
97- }
91+ get { return _values ; }
9892 }
9993
10094 public string this [ string name ]
@@ -117,7 +111,7 @@ private static void CheckNameFormat(string name, string parameterName)
117111 {
118112 if ( ! FormattingUtilities . ValidateHeaderToken ( name ) )
119113 {
120- throw new ArgumentException ( Properties . Resources . CookieInvalidName , parameterName ) ;
114+ throw Error . Argument ( parameterName , Properties . Resources . CookieInvalidName ) ;
121115 }
122116 }
123117
@@ -126,7 +120,7 @@ private static void CheckValueFormat(string value, string parameterName)
126120 // Empty string is a valid cookie value
127121 if ( value == null )
128122 {
129- throw new ArgumentNullException ( parameterName ) ;
123+ throw Error . ArgumentNull ( parameterName ) ;
130124 }
131125 }
132126 }
0 commit comments