/// <summary> /// Processes the database element in the SqlMap.config file. /// </summary> /// <param name="element">The element.</param> /// <param name="configurationStore">The configuration store.</param> private void ProcessDatabaseElement(Tag element, IConfigurationStore configurationStore) { MutableConfiguration config = new MutableConfiguration(element.Name); config.CreateAttributes(element.Attributes); configurationStore.AddDatabaseConfiguration(config); element.Configuration = config; }
/// <summary> /// Adds a database configuration item to the store. /// </summary> /// <example> /// <code> /// <database> /// <provider name="SQLite3"/> /// <dataSource name="ibatisnet.sqlmap" connectionString="Data Source=ibatisnet.sqlite;Version=3;"/> /// </database> /// </code> /// </example> public void AddDatabase(IDbProvider dbProvider, string dataSourceConnectionString) { // hack: serialize the object to IConfiguration so it can eventually be converted back to IDbProvider configurationStore.AddProviderConfiguration(ProviderSerializer.Serialize(dbProvider)); MutableConfiguration database = new MutableConfiguration(ConfigConstants.ELEMENT_DATABASE); MutableConfiguration provider = database.CreateChild("provider"); provider.CreateAttribute(ConfigConstants.ATTRIBUTE_NAME, dbProvider.Id); MutableConfiguration dataSource = database.CreateChild("dataSource"); dataSource.CreateAttribute(ConfigConstants.ATTRIBUTE_NAME, "defaultDataSource"); dataSource.CreateAttribute("connectionString", dataSourceConnectionString); configurationStore.AddDatabaseConfiguration(database); }