Beispiel #1
0
        public AssetServiceBase(IConfigSource config, string configName) : base(config)
        {
            if (!String.IsNullOrEmpty(configName))
                m_ConfigName = configName;

            string dllName = String.Empty;
            string connString = String.Empty;

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

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

            // We tried, but this doesn't exist. We can't proceed.
            if (String.IsNullOrEmpty(dllName))
                throw new Exception("No StorageProvider configured");

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

            m_Database.Initialize(connString);

            string loaderName = assetConfig.GetString("DefaultAssetLoader",
                    String.Empty);

            if (!String.IsNullOrEmpty(loaderName))
            {
                m_AssetLoader = LoadPlugin<IAssetLoader>(loaderName);

                if (m_AssetLoader == null)
                    throw new Exception("Asset loader could not be loaded");
            }
        }
Beispiel #2
0
        public override void Initialize(IPlugin plugin)
        {
            IAssetDataPlugin p = plugin as IAssetDataPlugin;

            p.Initialize(connect);
        }
Beispiel #3
0
        public AssetServiceBase(IConfigSource config, string configName) : base(config)
        {
            if (configName != string.Empty)
            {
                m_ConfigName = configName;
            }

            string dllName    = String.Empty;
            string connString = String.Empty;

            //
            // Try reading the [AssetService] section, if it exists
            //
            IConfig assetConfig = config.Configs[m_ConfigName];

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

            //
            // 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);
                }
            }

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

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

            m_Database.Initialize(connString);

            string loaderName = assetConfig.GetString("DefaultAssetLoader",
                                                      String.Empty);

            if (loaderName != String.Empty)
            {
                m_AssetLoader = LoadPlugin <IAssetLoader>(loaderName);

                if (m_AssetLoader == null)
                {
                    throw new Exception("Asset loader could not be loaded");
                }
            }
        }