/// <summary> /// Load account provider /// </summary> private void LoadProvider() { UserConfigurationSection sec = ConfigurationManager.GetSection("Giga.User") as UserConfigurationSection; if (sec == null) { LogManager.Error("Cannot read configuration section Giga.User! No account provider available!"); return; } AccountProviderConfigurationElement provElem = sec.AccountProviders.Get(sec.AccountProvider); if (provElem == null) { LogManager.Error("Cannot find configuration for Account Provider {0}!", sec.AccountProvider); return; } // Create provider instance try { Type type = Type.GetType(provElem.Type); _provider = type.Assembly.CreateInstance(type.FullName) as AccountProvider; } catch (Exception err) { LogManager.Error(err, "Create Account Provider {0} failed!", provElem.Type); return; } // Initialize the provider try { _provider.Initialize(provElem); } catch (Exception err) { LogManager.Error(err, "Initialize account provider {0} failed!", provElem.Name); _provider = null; return; } // Check if environment is ok if (!_provider.IsValid()) { // The dependencies of provider is not valid, re-install it to fix these problems try { _provider.Install(); } catch (Exception err) { LogManager.Error(err, "Cannot install account provider {0}!", provElem.Name); _provider = null; return; } } }