Exemplo n.º 1
0
        private DatabaseRegistry LoadConfig()
        {
            //var appEnv = CallContextServiceLocator.Locator.ServiceProvider.GetService(typeof(IApplicationEnvironment)) as IApplicationEnvironment;
            //var basePath = appEnv.ApplicationBasePath;

            var path = Setting.Instance.Get("DbSettingFilePath");

            var builder = new ConfigurationBuilder()
                          .AddJsonFile(path);

            var configuration = builder.Build();

            var databaseRegistry = new DatabaseRegistry();

            var descriptors = new List <DatabaseDescriptor>();

            foreach (var item in configuration.GetSection("databaseRegistry:databaseDescriptors").GetChildren())
            {
                var descriptor = new DatabaseDescriptor();
                descriptor.Name         = item.GetSection("databaseDescriptor").Value;
                descriptor.Address      = item.GetSection("address").Value;
                descriptor.DatabaseName = item.GetSection("databaseName").Value;
                descriptor.DatabaseType = EnumUtil.ParseEnum <DatabaseType>(item.GetSection("databaseType").Value);
                descriptor.UserName     = item.GetSection("userName").Value;
                descriptor.Password     = item.GetSection("password").Value;

                descriptors.Add(descriptor);
            }

            databaseRegistry.DatabaseDescriptors = descriptors;

            return(databaseRegistry);
        }
Exemplo n.º 2
0
 private DatabaseManager()
 {
     SetupMongoDbEnvironment();
     databases        = new Dictionary <string, IDatabase>();
     databaseRegistry = DatabaseConfigurationManager.Instance.DatabaseRegistry;
     databaseFactory  = new DatabaseFactory();
     CreateDatebases();
 }
Exemplo n.º 3
0
 private DatabaseConfigurationManager()
 {
     databaseRegistry = LoadConfig();
 }
Exemplo n.º 4
0
 public static void OnConfigure(IServiceProvider serviceProvider)
 {
     DatabaseRegistry.OnConfigure(serviceProvider);
 }