DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Protocol.LocalClient Class Reference
Inheritance diagram for Deveel.Data.Protocol.LocalClient:
Deveel.Data.Protocol.IClient

Public Member Functions

 LocalClient (ISystemContext systemContext)
 
void Dispose ()
 
IDatabaseClient ConnectToDatabase (IConfiguration config)
 

Properties

IConfiguration Configuration [get]
 
ISystemContext SystemContext [get, private set]
 
- Properties inherited from Deveel.Data.Protocol.IClient
IConfiguration Configuration [get]
 

Private Member Functions

 ~LocalClient ()
 
void Dispose (bool disposing)
 

Private Attributes

Dictionary< string, IDatabaseClientlocalClients
 
bool disposed
 

Detailed Description

Definition at line 8 of file LocalClient.cs.

Constructor & Destructor Documentation

Deveel.Data.Protocol.LocalClient.LocalClient ( ISystemContext  systemContext)
inline

Definition at line 12 of file LocalClient.cs.

12  {
13  if (systemContext == null)
14  throw new ArgumentNullException("systemContext");
15 
16  if (!(systemContext is IDatabaseHandler))
17  throw new ArgumentException("The system context does not handle databases");
18 
19  SystemContext = systemContext;
20  localClients = new Dictionary<string, IDatabaseClient>();
21  }
Dictionary< string, IDatabaseClient > localClients
Definition: LocalClient.cs:9
Deveel.Data.Protocol.LocalClient.~LocalClient ( )
inlineprivate

Definition at line 23 of file LocalClient.cs.

23  {
24  Dispose(false);
25  }

Member Function Documentation

IDatabaseClient Deveel.Data.Protocol.LocalClient.ConnectToDatabase ( IConfiguration  config)
inline

Implements Deveel.Data.Protocol.IClient.

Definition at line 56 of file LocalClient.cs.

56  {
57  var dbConfig = Configuration.Merge(config);
58  var databaseName = config.DatabaseName();
59  if (String.IsNullOrEmpty(databaseName))
60  throw new ArgumentException("The given configuration does not provide any database name.");
61 
62  IDatabaseClient client;
63  if (!localClients.TryGetValue(databaseName, out client)) {
64  var dbHandler = SystemContext as IDatabaseHandler;
65  if (dbHandler == null)
66  throw new InvalidOperationException("The system context does not handle databases");
67 
68  var database = dbHandler.GetDatabase(databaseName);
69  if (database == null)
70  throw new InvalidOperationException(String.Format("The database '{0}' could not be found in the current context.", databaseName));
71 
72  client = new LocalDatabaseClient(this, database);
73  localClients[databaseName] = client;
74  }
75 
76  return client;
77  }
A long string in the system.
Dictionary< string, IDatabaseClient > localClients
Definition: LocalClient.cs:9
void Deveel.Data.Protocol.LocalClient.Dispose ( )
inline

Definition at line 27 of file LocalClient.cs.

27  {
28  Dispose(true);
29  GC.SuppressFinalize(this);
30  }
void Deveel.Data.Protocol.LocalClient.Dispose ( bool  disposing)
inlineprivate

Definition at line 32 of file LocalClient.cs.

32  {
33  if (!disposed) {
34  if (disposing) {
35  if (localClients != null) {
36  foreach (var client in localClients.Values) {
37  client.Dispose();
38  }
39 
40  localClients.Clear();
41  }
42  }
43 
44  disposed = true;
45  }
46 
47  localClients = null;
48  }
Dictionary< string, IDatabaseClient > localClients
Definition: LocalClient.cs:9

Member Data Documentation

bool Deveel.Data.Protocol.LocalClient.disposed
private

Definition at line 10 of file LocalClient.cs.

Dictionary<string, IDatabaseClient> Deveel.Data.Protocol.LocalClient.localClients
private

Definition at line 9 of file LocalClient.cs.

Property Documentation

IConfiguration Deveel.Data.Protocol.LocalClient.Configuration
get

Definition at line 50 of file LocalClient.cs.

ISystemContext Deveel.Data.Protocol.LocalClient.SystemContext
getprivate set

Definition at line 54 of file LocalClient.cs.


The documentation for this class was generated from the following file: