protected override void InitializeImpl() { lock (instance) { if (RuntimeUtils.Initializable(this.State)) { string meth = "Initialize"; this.State = RunState.Initializing; this.logger = LogManager.Instance.GetProvider(typeof(UserAffilationSecurityManager)); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(NameReflectionUtils.GetType(TypeNameReference.Parse("Osrs.WellKnown.FieldActivities.Providers.PgFieldActivityProviderFactory, Osrs.WellKnown.FieldActivities.Providers.Postgres")), "connectionString"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { if (NpgSqlCommandUtils.TestConnection(tName)) { Db.ConnectionString = tName; this.initialized = true; this.State = RunState.Initialized; return; } } else { Log(meth, LogLevel.Error, "Failed to get connectionString param value"); } } else { Log(meth, LogLevel.Error, "Failed to get connectionString param"); } } else { Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider"); } this.State = RunState.FailedInitializing; } } }
public void Bootstrap(TypeNameReference logfactory) { lock (this.syncRoot) { if (RuntimeUtils.Bootstrappable(this.State) || this.State == RunState.Bootstrapping) { this.State = RunState.Bootstrapping; if (logfactory != null) { this.provider = new MemoryLoggerFactory(); this.provider.Initialize(); if (!logfactory.Equals(TypeNameReference.Create(typeof(MemoryLoggerFactory)))) //confirm we're not just using memory logger { LogProviderFactory configFinal = NameReflectionUtils.CreateInstance <LogProviderFactory>(logfactory); if (configFinal != null) { if (configFinal.Initialize()) { this.provider = configFinal; //for the time being foreach (LogItem cur in MemoryLoggerFactory.Items) { LogProviderBase log = this.provider.GetLogger(NameReflectionUtils.GetType(cur.TypeName)); if (log != null) { log.Log(cur.Severity, cur.Message); } } MemoryLoggerFactory.Items.Clear(); this.State = RunState.Bootstrapped; return; } } } else //permanent logger is memory logger, so do nothing else { this.State = RunState.Bootstrapped; return; } } this.provider = null; this.State = RunState.FailedBootstrapping; } } }