private void Initialize() { _dbs = GlobalConfig.ReadValue(ORM, DATABASE).Split(Delimiter, StringSplitOptions.RemoveEmptyEntries); foreach (var db in _dbs) { string id = db.Trim(); if (string.IsNullOrEmpty(id)) { ConfigExceptionHelper.ThrowDatabaseIdNotDefined(); } string dialectId = GlobalConfig.ReadValue(ORM, string.Format(DIALECT_ID_ATTR, id)); if (string.IsNullOrEmpty(dialectId)) { ConfigExceptionHelper.ThrowDialectIdForDatabaseNotDefined(id); } string cnnstr = GlobalConfig.ReadValue(ORM, string.Format(CNN_STR_ATTR, id)); string provider = null; string dialectProvider = null; string providerKey = string.Format(PROVIDER_ATTR, id); string providerDialectKey = string.Format(DIALECT_PROVIDER_ATTR, id); if (GlobalConfig.ExistsKey(ORM, providerKey)) { provider = GlobalConfig.ReadValue(ORM, providerKey); } if (GlobalConfig.ExistsKey(ORM, providerDialectKey)) { dialectProvider = GlobalConfig.ReadValue(ORM, providerDialectKey); } _databases.Add(id, new DatabaseInfo(cnnstr, provider, dialectId, dialectProvider)); } }
public string[] GetObjectMapPaths() { string files = GlobalConfig.ReadValue(ORM, OBJECT_MAP); string[] paths; if (string.IsNullOrEmpty(files)) { paths = new string[] { } } ; else { paths = files.Split(Delimiter, StringSplitOptions.RemoveEmptyEntries); } for (int i = 0; i < paths.Length; i++) { string path = Runtime.GetPath(paths[i]); if (!File.Exists(path)) { ConfigExceptionHelper.ThrowMapFileNotExist(path); } paths[i] = path; } return(paths); }
public IDatabaseInfo GetDatabaseInfo(string dbId) { dbId.ThrowIfNullArgument(nameof(dbId)); IDatabaseInfo result; if (!_databases.TryGetValue(dbId, out result)) { ConfigExceptionHelper.ThrowDatabaseNotDefined(dbId); return(null); } else { return(result); } }