2003-03-08 Tim Coleman <tim@timcoleman.com>
[mono.git] / mcs / class / System.Data.OracleClient / System.Data.OracleClient.Oci / OciServiceHandle.cs
1 // 
2 // OciServiceHandle.cs 
3 //  
4 // Part of managed C#/.NET library System.Data.OracleClient.dll
5 //
6 // Part of the Mono class libraries at
7 // mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
8 //
9 // Assembly: System.Data.OracleClient.dll
10 // Namespace: System.Data.OracleClient.Oci
11 // 
12 // Author: 
13 //     Tim Coleman <tim@timcoleman.com>
14 //         
15 // Copyright (C) Tim Coleman, 2003
16 // 
17
18 using System;
19 using System.Runtime.InteropServices;
20
21 namespace System.Data.OracleClient.Oci {
22         internal sealed class OciServiceHandle : OciHandle
23         {
24                 #region Fields
25
26                 bool disposed = false;
27                 OciSessionHandle session;
28                 OciServerHandle server;
29
30                 OciErrorHandle errorHandle;
31
32                 #endregion // Fields
33
34                 #region Constructors
35
36                 public OciServiceHandle (OciHandle parent, IntPtr handle)
37                         : base (OciHandleType.Service, parent, handle)
38                 {
39                 }
40
41                 #endregion // Constructors
42
43                 #region Properties
44
45                 public OciErrorHandle ErrorHandle {
46                         get { return errorHandle; }
47                         set { errorHandle = value; }
48                 }
49
50                 #endregion // Properties
51
52                 #region Methods
53
54                 protected override void Dispose (bool disposing)
55                 {
56                         if (!disposed) {
57                                 try {
58                                         if (disposing) {
59                                                 if (server != null)
60                                                         server.Dispose ();
61                                                 if (session != null)
62                                                         session.Dispose ();
63                                         }
64                                         disposed = true;
65                                 } finally {
66                                         base.Dispose (disposing);
67                                 }
68                         }
69                 }
70
71                 public bool SetServer (OciServerHandle handle)
72                 {
73                         server = handle;
74                         int status = OciGlue.OCIAttrSet (this,
75                                                         HandleType,
76                                                         server,
77                                                         0,
78                                                         OciAttributeType.Server,
79                                                         ErrorHandle);
80                         return (status == 0);
81                 }
82
83                 public bool SetSession (OciSessionHandle handle)
84                 {
85                         session = handle;
86                         int status = OciGlue.OCIAttrSet (this,
87                                                         HandleType,
88                                                         session,
89                                                         0,
90                                                         OciAttributeType.Session,
91                                                         ErrorHandle);
92                         return (status == 0);
93                 }
94
95                 #endregion // Methods
96         }
97 }