NameValuePair.cs 2.1 KB

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