f0b7cdc17f41c2970ff7ab621e206da702ee8eea
[mono.git] / mcs / class / referencesource / System.Data / System / Data / Common / NameValuePair.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="NameValuePair.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 // <owner current="true" primary="true">Microsoft</owner>
6 // <owner current="true" primary="false">Microsoft</owner>
7 //------------------------------------------------------------------------------
8
9 namespace System.Data.Common {
10
11     using System;
12     using System.Data.Common;
13     using System.Diagnostics;
14     using System.Runtime.Serialization;
15
16     [Serializable] // MDAC 83147
17     sealed internal class NameValuePair {
18         readonly private string _name;
19         readonly private string _value;
20         [OptionalField(VersionAdded=2)]
21         readonly private int _length;
22         private NameValuePair _next;
23
24         internal NameValuePair(string name, string value, int length) {
25             System.Diagnostics.Debug.Assert(!ADP.IsEmpty(name), "empty keyname");
26             _name = name;
27             _value = value;
28             _length = length;
29         }
30
31         internal int Length {
32             get {
33                 // this property won't exist when deserialized from Everett to Whidbey
34                 // it shouldn't matter for DbConnectionString/DbDataPermission
35                 // which should only use Length during construction
36                 // not deserialization or post-ctor runtime
37                 Debug.Assert(0 < _length, "NameValuePair zero Length usage");
38                 return _length;
39             }
40         }
41         internal string Name {
42             get {
43                 return _name;
44             }
45         }
46         internal NameValuePair Next {
47             get {
48                 return _next;
49             }
50             set {
51                 if ((null != _next) || (null == value)) {
52                     throw ADP.InternalError(ADP.InternalErrorCode.NameValuePairNext);
53                 }
54                 _next = value;
55             }
56         }
57         internal string Value {
58             get {
59                 return _value;
60             }
61         }
62     }
63 }