DbConnection.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //
  2. // System.Data.Common.DbConnection
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2003
  8. //
  9. //
  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.ComponentModel;
  33. using System.Data;
  34. using System.EnterpriseServices;
  35. namespace System.Data.Common {
  36. public abstract class DbConnection : Component, IDbConnection, IDisposable
  37. {
  38. #region Fields
  39. bool disposed = false;
  40. #endregion //Fields
  41. #region Constructors
  42. protected DbConnection ()
  43. {
  44. }
  45. #endregion // Constructors
  46. #region Properties
  47. public abstract string ConnectionString { get; set; }
  48. public abstract int ConnectionTimeout { get; }
  49. public abstract string Database { get; }
  50. public abstract string DataSource { get; }
  51. public abstract string ServerVersion { get; }
  52. public abstract ConnectionState State { get; }
  53. #endregion // Properties
  54. #region Methods
  55. protected abstract DbTransaction BeginDbTransaction (IsolationLevel isolationLevel);
  56. [MonoTODO]
  57. public DbTransaction BeginTransaction ()
  58. {
  59. throw new NotImplementedException ();
  60. }
  61. [MonoTODO]
  62. public DbTransaction BeginTransaction (IsolationLevel isolationLevel)
  63. {
  64. throw new NotImplementedException ();
  65. }
  66. public abstract void ChangeDatabase (string databaseName);
  67. public abstract void Close ();
  68. public DbCommand CreateCommand ()
  69. {
  70. return CreateDbCommand ();
  71. }
  72. protected override void Dispose (bool disposing)
  73. {
  74. if (!disposed) {
  75. try {
  76. if (disposing) {
  77. // unmanaged cleanup
  78. }
  79. disposed = true;
  80. } finally {
  81. base.Dispose (disposing);
  82. }
  83. }
  84. }
  85. protected abstract DbCommand CreateDbCommand ();
  86. [MonoTODO]
  87. public virtual void EnlistTransaction (ITransaction transaction)
  88. {
  89. throw new NotImplementedException ();
  90. }
  91. [MonoTODO]
  92. public virtual void EnlistDistributedTransaction (ITransaction transaction)
  93. {
  94. throw new NotImplementedException ();
  95. }
  96. [MonoTODO]
  97. public virtual DataTable GetSchema ()
  98. {
  99. throw new NotImplementedException ();
  100. }
  101. [MonoTODO]
  102. public virtual DataTable GetSchema (string collectionName)
  103. {
  104. throw new NotImplementedException ();
  105. }
  106. [MonoTODO]
  107. public virtual DataTable GetSchema (string collectionName, string[] restrictionValues)
  108. {
  109. throw new NotImplementedException ();
  110. }
  111. IDbTransaction IDbConnection.BeginTransaction ()
  112. {
  113. return BeginTransaction ();
  114. }
  115. IDbTransaction IDbConnection.BeginTransaction (IsolationLevel il)
  116. {
  117. return BeginTransaction (il);
  118. }
  119. IDbCommand IDbConnection.CreateCommand ()
  120. {
  121. return CreateCommand ();
  122. }
  123. public abstract void Open ();
  124. #endregion // Methods
  125. }
  126. }
  127. #endif