* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / FirebirdSql.Data.Firebird / FirebirdSql.Data.Firebird / Services / FbServerProperties.cs
1 /*
2  *      Firebird ADO.NET Data provider for .NET and Mono 
3  * 
4  *         The contents of this file are subject to the Initial 
5  *         Developer's Public License Version 1.0 (the "License"); 
6  *         you may not use this file except in compliance with the 
7  *         License. You may obtain a copy of the License at 
8  *         http://www.firebirdsql.org/index.php?op=doc&id=idpl
9  *
10  *         Software distributed under the License is distributed on 
11  *         an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
12  *         express or implied. See the License for the specific 
13  *         language governing rights and limitations under the License.
14  * 
15  *      Copyright (c) 2002, 2005 Carlos Guzman Alvarez
16  *      All Rights Reserved.
17  */
18
19 using System;
20 using System.Collections;
21
22 using FirebirdSql.Data.Common;
23
24 namespace FirebirdSql.Data.Firebird.Services
25 {
26         /// <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/overview/*'/>
27         public sealed class FbServerProperties : FbService
28         {
29                 #region Properties
30
31                 /// <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="Version"]/*'/>
32                 public int Version
33                 {
34                         get { return this.GetInt32(IscCodes.isc_info_svc_version); }
35                 }
36
37                 /// <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="ServerVersion"]/*'/>
38                 public string ServerVersion
39                 {
40                         get { return this.GetString(IscCodes.isc_info_svc_server_version); }
41                 }
42
43                 /// <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="Implementation"]/*'/>
44                 public string Implementation
45                 {
46                         get { return this.GetString(IscCodes.isc_info_svc_implementation); }
47                 }
48
49                 /// <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="RootDirectory"]/*'/>
50                 public string RootDirectory
51                 {
52                         get { return this.GetString(IscCodes.isc_info_svc_get_env); }
53                 }
54
55                 /// <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="LockManager"]/*'/>
56                 public string LockManager
57                 {
58                         get { return this.GetString(IscCodes.isc_info_svc_get_env_lock); }
59                 }
60
61                 /// <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="MessageFile"]/*'/>
62                 public string MessageFile
63                 {
64                         get { return this.GetString(IscCodes.isc_info_svc_get_env_msg); }
65                 }
66
67                 /// <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="DatabasesInfo"]/*'/>
68                 public FbDatabasesInfo DatabasesInfo
69                 {
70                         get
71                         {
72                                 ArrayList info = this.GetInfo(IscCodes.isc_info_svc_svr_db_info);
73
74                                 return info.Count != 0 ? (FbDatabasesInfo)info[0] : new FbDatabasesInfo();
75                         }
76                 }
77
78                 /// <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/property[@name="ServerConfig"]/*'/>
79                 public FbServerConfig ServerConfig
80                 {
81                         get
82                         {
83                                 ArrayList info = this.GetInfo(IscCodes.isc_info_svc_get_config);
84
85                                 return info.Count != 0 ? (FbServerConfig)info[0] : new FbServerConfig();
86                         }
87                 }
88
89                 #endregion
90
91                 #region Constructors
92
93                 /// <include file='Doc/en_EN/FbServerProperties.xml' path='doc/class[@name="FbServerProperties"]/constructor[@name="FbServerProperties"]/*'/>
94                 public FbServerProperties() : base()
95                 {
96                 }
97
98                 #endregion
99
100                 #region Private Methods
101
102                 private string GetString(int item)
103                 {
104                         ArrayList info = this.GetInfo(item);
105
106                         return info.Count != 0 ? (string)info[0] : null;
107                 }
108
109                 private int GetInt32(int item)
110                 {
111                         ArrayList info = this.GetInfo(item);
112
113                         return info.Count != 0 ? (int)info[0] : 0;
114                 }
115
116                 private ArrayList GetInfo(int item)
117                 {
118                         return this.GetInfo(new byte[] { (byte)item });
119                 }
120
121                 private ArrayList GetInfo(byte[] items)
122                 {
123                         byte[] buffer = this.QueryService(items);
124
125                         return this.ParseQueryInfo(buffer);
126                 }
127
128                 #endregion
129         }
130 }