DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
SystemContext.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 
20 using Deveel.Data.Diagnostics;
21 using Deveel.Data.Services;
22 
23 namespace Deveel.Data {
28  public sealed class SystemContext : Context, ISystemContext {
29  private IScope scope;
30 
31  internal SystemContext(IConfiguration configuration, ServiceContainer container) {
32  if (configuration == null)
33  throw new ArgumentNullException("configuration");
34 
35  Configuration = configuration;
36 
37  scope = container.OpenScope(ContextNames.System);
38  scope.RegisterInstance<IConfiguration>(configuration);
39  scope.RegisterInstance<ISystemContext>(this);
40 
41  EventRegistry = new EventRegistry(this);
42  }
43 
47  public IConfiguration Configuration { get; private set; }
48 
49  protected override IScope ContextScope {
50  get { return scope; }
51  }
52 
53  protected override string ContextName {
54  get { return ContextNames.System; }
55  }
56 
58  return new DatabaseContext(this, configuration);
59  }
60 
62  var dbConfig = Configuration.MergeWith(configuration);
63  return CreateDatabaseContext(dbConfig);
64  }
65 
67  get { return EventRegistry; }
68  }
69 
70  public EventRegistry EventRegistry { get; private set; }
71 
72  protected override void Dispose(bool disposing) {
73  if (disposing) {
74  if (scope != null)
75  scope.Dispose();
76  }
77 
78  scope = null;
79  base.Dispose(true);
80  }
81  }
82 }
The context of a single database within a system.
The execution context of a database system, that is defining the configurations and the components us...
SystemContext(IConfiguration configuration, ServiceContainer container)
This is the context of a database system, that handles the configurations and services used by all th...
IDatabaseContext CreateDatabaseContext(IConfiguration configuration)
DatabaseContext CreateDatabaseContext(IConfiguration configuration)
Implementations of this interface handle the registration of events fired within the system...
Defines the contract for the configuration node of a component within the system or of the system its...
override void Dispose(bool disposing)