Пример #1
0
        public InventoryServiceBase(IConfigSource config) : base(config)
        {
            string dllName    = String.Empty;
            string connString = String.Empty;

            //
            // Try reading the [DatabaseService] section first, if it exists
            //
            IConfig dbConfig = config.Configs["DatabaseService"];

            if (dbConfig != null)
            {
                dllName    = dbConfig.GetString("StorageProvider", String.Empty);
                connString = dbConfig.GetString("ConnectionString", String.Empty);
            }

            //
            // Try reading the more specific [InventoryService] section, if it exists
            //
            IConfig inventoryConfig = config.Configs["InventoryService"];

            if (inventoryConfig != null)
            {
                dllName    = inventoryConfig.GetString("StorageProvider", dllName);
                connString = inventoryConfig.GetString("ConnectionString", connString);
            }

            //
            // We tried, but this doesn't exist. We can't proceed.
            //
            if (dllName.Equals(String.Empty))
            {
                throw new Exception("No InventoryService configuration");
            }

            m_Database = LoadPlugin <IInventoryDataPlugin>(dllName);
            if (m_Database == null)
            {
                throw new Exception("Could not find a storage interface in the given module");
            }

            m_Database.Initialise(connString);
        }
        public InventoryServiceBase(IConfigSource config) : base(config)
        {
            string dllName = String.Empty;
            string connString = String.Empty;

            //
            // Try reading the [DatabaseService] section first, if it exists
            //
            IConfig dbConfig = config.Configs["DatabaseService"];
            if (dbConfig != null)
            {
                dllName = dbConfig.GetString("StorageProvider", String.Empty);
                connString = dbConfig.GetString("ConnectionString", String.Empty);
            }

            //
            // Try reading the more specific [InventoryService] section, if it exists
            //
            IConfig inventoryConfig = config.Configs["InventoryService"];
            if (inventoryConfig != null)
            {
                dllName = inventoryConfig.GetString("StorageProvider", dllName);
                connString = inventoryConfig.GetString("ConnectionString", connString);
            }

            //
            // We tried, but this doesn't exist. We can't proceed.
            //
            if (dllName.Equals(String.Empty))
                throw new Exception("No InventoryService configuration");

            m_Database = LoadPlugin<IInventoryDataPlugin>(dllName);
            if (m_Database == null)
                throw new Exception("Could not find a storage interface in the given module");

            m_Database.Initialise(connString);
        }
Пример #3
0
        public override void Initialise(IPlugin plugin)
        {
            IInventoryDataPlugin p = plugin as IInventoryDataPlugin;

            p.Initialise(connect);
        }
Пример #4
0
 protected override void InitService(object service)
 {
     ClearDB();
     db = (IInventoryDataPlugin)service;
     db.Initialise(m_connStr);
 }