public WxExampleServiceBase(IConfigSource config) : base(config) { string dllName = String.Empty; // Try reading the [DatabaseService] section, if it exists // IConfig dbConfig = config.Configs["DatabaseService"]; if (dbConfig != null) { if (dllName == String.Empty) { dllName = dbConfig.GetString("StorageProvider", String.Empty); } if (connString == String.Empty) { connString = dbConfig.GetString("ConnectionString", String.Empty); } } // // [WxService] section overrides [DatabaseService], if it exists // IConfig WxConfig = config.Configs["WxExampleService"]; if (WxConfig != null) { // Look at the ini [WxService] to see the database setup. // We give Wx.Data.dll as the StorageProvider, so we load // our custom database handler. // Have a look at Wx.Data. We do migrations on load. // dllName = WxConfig.GetString("StorageProvider", dllName); connString = WxConfig.GetString("ConnectionString", connString); realm = WxConfig.GetString("Realm", realm); } // // We tried, but this doesn't exist. We can't proceed. // if (dllName.Equals(String.Empty)) { throw new Exception("No StorageProvider configured"); } // This is our example database // Look at Wx.Data m_Database = LoadPlugin <IWxMyData>(dllName, new Object[] { connString, realm }); if (m_Database == null) { throw new Exception("Could not find a storage interface in the given module"); } }
public WxExampleServiceBase(IConfigSource config) : base(config) { string dllName = String.Empty; // Try reading the [DatabaseService] section, if it exists // IConfig dbConfig = config.Configs["DatabaseService"]; if (dbConfig != null) { if (dllName == String.Empty) dllName = dbConfig.GetString("StorageProvider", String.Empty); if (connString == String.Empty) connString = dbConfig.GetString("ConnectionString", String.Empty); } // // [WxService] section overrides [DatabaseService], if it exists // IConfig WxConfig = config.Configs["WxExampleService"]; if (WxConfig != null) { // Look at the ini [WxService] to see the database setup. // We give Wx.Data.dll as the StorageProvider, so we load // our custom database handler. // Have a look at Wx.Data. We do migrations on load. // dllName = WxConfig.GetString("StorageProvider", dllName); connString = WxConfig.GetString("ConnectionString", connString); realm = WxConfig.GetString("Realm", realm); } // // We tried, but this doesn't exist. We can't proceed. // if (dllName.Equals(String.Empty)) throw new Exception("No StorageProvider configured"); // This is our example database // Look at Wx.Data m_Database = LoadPlugin<IWxMyData>(dllName, new Object[] { connString, realm }); if (m_Database == null) throw new Exception("Could not find a storage interface in the given module"); }