2
0

DbConnectionOptions.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //
  2. // System.Data.Common.DbConnectionOptions
  3. // adapted from older (pre beta1) DbConnectionString
  4. //
  5. // Authors:
  6. // Tim Coleman ([email protected])
  7. // Sebastien Pouliot <[email protected]>
  8. //
  9. // Copyright (C) Tim Coleman, 2003
  10. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. #if NET_2_0
  32. using System.Collections;
  33. using System.Collections.Specialized;
  34. using System.Text;
  35. namespace System.Data.Common {
  36. public class DbConnectionOptions {
  37. #region Fields
  38. internal NameValueCollection options;
  39. #endregion // Fields
  40. #region Constructors
  41. [MonoTODO]
  42. protected internal DbConnectionOptions (DbConnectionOptions connectionOptions)
  43. {
  44. options = connectionOptions.options;
  45. }
  46. [MonoTODO]
  47. public DbConnectionOptions (string connectionString)
  48. {
  49. options = new NameValueCollection ();
  50. ParseConnectionString (connectionString);
  51. }
  52. [MonoTODO]
  53. public DbConnectionString (string connectionString, Hashtable synonyms, bool useFirstKeyValuePair)
  54. : this (connectionString)
  55. {
  56. }
  57. #endregion // Constructors
  58. #region Properties
  59. [MonoTODO]
  60. public bool IsEmpty {
  61. get { throw new NotImplementedException (); }
  62. }
  63. public string this [string keyword] {
  64. get { return options [keyword]; }
  65. }
  66. public ICollection Keys {
  67. get { return options.Keys; }
  68. }
  69. #endregion // Properties
  70. #region Methods
  71. [MonoTODO]
  72. protected void BuildConnectionString (StringBuilder builder, string[] withoutOptions, string insertValue)
  73. {
  74. throw new NotImplementedException ();
  75. }
  76. public bool ContainsKey (string keyword)
  77. {
  78. return (options.Get (keyword) != null);
  79. }
  80. public bool ConvertValueToBoolean (string keyname, bool defaultvalue)
  81. {
  82. if (ContainsKey (keyname))
  83. return Boolean.Parse (this [keyname].Trim ());
  84. return defaultvalue;
  85. }
  86. public int ConvertValueToInt32 (string keyname, int defaultvalue)
  87. {
  88. if (ContainsKey (keyname))
  89. return Int32.Parse (this [keyname].Trim ());
  90. return defaultvalue;
  91. }
  92. [MonoTODO]
  93. public bool ConvertValueToIntegratedSecurity ()
  94. {
  95. throw new NotImplementedException ();
  96. }
  97. public string ConvertValueToString (string keyname, string defaultValue)
  98. {
  99. if (ContainsKey (keyname))
  100. return this [keyname];
  101. return defaultValue;
  102. }
  103. [MonoTODO]
  104. protected internal virtual PermissionSet CreatePermissionSet ()
  105. {
  106. throw new NotImplementedException ();
  107. }
  108. [MonoTODO]
  109. protected internal virtual string Expand ()
  110. {
  111. throw new NotImplementedException ();
  112. }
  113. [MonoTODO]
  114. public static string RemoveKeyValuePairs (string connectionString, string[] keynames)
  115. {
  116. throw new NotImplementedException ();
  117. }
  118. [MonoTODO]
  119. public string UsersConnectionString (bool hisPasswordPwd)
  120. {
  121. throw new NotImplementedException ();
  122. }
  123. #endregion // Methods
  124. }
  125. }
  126. #endif