internal static bool Initialize() { LogProviderBase log = null; if (LogManager.Instance.State == RunState.Running) { log = LogManager.Instance.GetProvider(typeof(OncorServer)); } if (log == null) { log = new NullLogger(typeof(OncorServer)); } ConfigurationProviderBase prov = ConfigurationManager.Instance.GetProvider(); if (prov != null) { ConfigurationParameter param = prov.Get(typeof(HttpListenerServerListener), "listenerUrls"); List <string> listenUrls = new List <string>(); if (param != null) { string[] tmp = (string[])param.Value; listenUrls.AddRange(tmp); List <IHandlerMapper> handlers = new List <IHandlerMapper>(); handlers.Add(InitApi(prov)); handlers.Add(InitFiles(prov)); Server = InitServer(listenUrls, handlers); return(Server != null); } } return(false); }
protected override void BootstrapImpl() { lock (this.syncRoot) { this.State = RunState.Bootstrapping; try { ConfigurationProviderBase prov = ConfigurationManager.Instance.GetProvider(); if (prov != null) { ConfigurationParameter param = prov.Get(typeof(LogManager), "provider"); if (param != null) { string fName = (string)param.Value; if (!string.IsNullOrEmpty(fName)) { TypeNameReference tnr = TypeNameReference.Parse(fName, ','); if (tnr != null) { this.Bootstrap(tnr); return; } } } } } catch { } this.State = RunState.FailedBootstrapping; } }
protected override bool Initialize() { lock (this) { if (!this.initialized) { ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(PgUserPasswordHistoryProviderFactory), "connectionString"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { if (NpgSqlCommandUtils.TestConnection(tName)) { Db.ConnectionString = tName; this.initialized = true; return(true); } } } } } } return(false); }
protected override ConfigurationProviderBase CreateConfigurationProviderCore() { if (configurationProvider == null) { configurationProvider = new ConfigurationProviderLocal(); } return(configurationProvider); }
/// <summary> /// Tries to intialize by configuration, if no configuartion parameter is found, tries to use local static configuration property. /// If that is not found, initialization fails. /// </summary> /// <returns></returns> protected override bool Initialize() { lock (syncRoot) { LogProviderBase logger = LogManager.Instance.GetProvider(typeof(FlatFileLogFactory)); if (logger == null) { logger = new NullLogger(typeof(FlatFileLogFactory)); } ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(FlatFileLogFactory), "fileName"); if (param != null) { try { string fileName = (string)param.Value; if (Init(fileName)) { logger = null; //make sure to clear it out return(true); } else { logger.Log(1000, "InitImpl: Failed to get or create log file: " + fileName); } } catch { logger.Log(1000, "InitImpl: Failed to get configuration param"); } } else { if (Init(Configuration)) { logger = null; //make sure to clear it out return(true); } logger.Log(1000, "InitImpl: Failed to get config parameter: fileName"); } } else { logger.Log(1000, "InitImpl: Failed to get config provider"); if (Init(Configuration)) { logger = null; //make sure to clear it out return(true); } } logger = null; //make sure to clear it out return(false); } }
static void Main(string[] args) { ConfigurationManager.Instance.Bootstrap(); ConfigurationManager.Instance.Initialize(); ConfigurationManager.Instance.Start(); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); ConfigurationParameter param = config.Get(typeof(Program), "hostList"); Console.WriteLine("Enter to exit"); Console.ReadLine(); }
public void Bootstrap() { lock (instance) { if (RuntimeUtils.Bootstrappable(this.State)) { string meth = "Bootstrap"; this.State = RunState.Bootstrapping; this.logger = LogManager.Instance.GetProvider(typeof(IdentityManager)); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(IdentityManager), "provider"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { TypeNameReference typeName = TypeNameReference.Parse(tName); if (typeName != null) { IdentityConfiguration iConfig = new IdentityConfiguration(); iConfig.FactoryTypeName = typeName; Bootstrap(iConfig); return; } else { Log(meth, LogLevel.Error, "Failed to parse provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get provider param"); } } else { Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider"); } this.State = RunState.FailedBootstrapping; } } }
protected override void InitializeImpl() { lock (instance) { if (RuntimeUtils.Initializable(this.State)) { string meth = "Initialize"; this.State = RunState.Initializing; this.logger = LogManager.Instance.GetProvider(typeof(InstrumentManager)); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(InstrumentManager), "provider"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { TypeNameReference typeName = TypeNameReference.Parse(tName); if (typeName != null) { this.Initialize(typeName); return; } else { Log(meth, LogLevel.Error, "Failed to parse role provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get role provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get role provider param"); } } else { Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider"); } this.State = RunState.FailedInitializing; } } }
protected override ConfigurationProviderBase CreateConfigurationProviderCore() { if (configurationProvider == null) { if (ConfigurationProviderFactory == null) { throw CreateFactoryNotInitializedException("ConfigurationProviderFactory", "ConfigurationProviderBase"); } configurationProvider = ConfigurationProviderFactory(); } return(configurationProvider); }
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; } } }
protected override void InitializeImpl() { lock (instance) { if (RuntimeUtils.Initializable(this.State)) { string meth = "Initialize"; this.State = RunState.Initializing; this.logger = LogManager.Instance.GetProvider(typeof(EntityBundleManager)); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(EntityBundleProvider), "connectionString"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { if (NpgSqlCommandUtils.TestConnection(tName)) { Db.ConnectionString = tName; Log(meth, LogLevel.Info, "Succeeded"); 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; } } }
protected override bool Initialize() { lock (instance) { if (!this.initialized) { string meth = "Initialize"; this.logger = LogManager.Instance.GetProvider(myType); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(myType, "connectionString"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { if (NpgSqlCommandUtils.TestConnection(tName)) { Db.ConnectionString = tName; this.initialized = true; return(true); } } 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"); } } } return(false); }
internal bool Init() { string meth = "Initialize"; this.logger = LogManager.Instance.GetProvider(typeof(DetRegistry)); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(DetRegistry), "connectionString"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { if (NpgSqlCommandUtils.TestConnection(tName)) { this.connString = tName; Log(meth, LogLevel.Info, "Succeeded"); return(true); } } 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"); } return(false); }
protected internal override bool Initialize() { ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); ConfigurationParameter param = config.Get(typeof(JsonProviderFactory), "fileName"); if (param == null) { return(false); } try { string fileName = (string)param.Value; JsonProvider p = new JsonProvider(this.configs); //init will fill this dictionary for reuse bool x = p.Init(Path.GetFullPath(fileName)); if (x) { return(true); //so we can finish init successfully } } catch { } return(false); }
private static IHandlerMapper InitFiles(ConfigurationProviderBase prov) { ConfigurationParameter param = prov.Get(typeof(SimpleFileHandler), "rootDirectory"); if (param != null) { string rootDir = (string)param.Value; param = prov.Get(typeof(SimpleFileHandler), "logicalDirectory"); if (param != null) { string localDir = (string)param.Value; string[] defFiles; param = prov.Get(typeof(SimpleFileHandler), "defaultFiles"); if (param != null) { defFiles = (string[])param.Value; FileExtensions exts = new FileExtensions(); param = prov.Get(typeof(SimpleFileHandler), "allowedExtensions"); if (param != null) { string[] tmp = (string[])param.Value; foreach (string cur in tmp) { exts.Add(cur); } SimpleFileHandler handler = new SimpleFileHandler(rootDir, defFiles, MimeTypes.GetAllWellKnown(), exts, new FileExtensions()); //so we can also have static files return(new UrlBaseMapHandler(handler, new string[] { localDir })); } } } } return(null); }
protected override void BootstrapImpl() { lock (instance) { if (RuntimeUtils.Bootstrappable(this.State)) { string meth = "Bootstrap"; this.State = RunState.Bootstrapping; this.logger = LogManager.Instance.GetProvider(typeof(SessionManager)); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(SessionManager), "provider"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { TypeNameReference typeName = TypeNameReference.Parse(tName); if (typeName != null) { uint sessionDuration; param = config.Get(typeof(SessionManager), "duration"); if (param != null) { try { sessionDuration = (uint)(int)param.Value; if (sessionDuration == 0) { sessionDuration = 900; //default if not provided 15 minutes } this.Bootstrap(typeName, sessionDuration); return; } catch { } Log(meth, LogLevel.Error, "Failed to parse duration param value"); } else { Log(meth, LogLevel.Error, "Failed to get duration param"); } } else { Log(meth, LogLevel.Error, "Failed to parse provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get provider param"); } } else { Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider"); } this.State = RunState.FailedBootstrapping; } } }
protected override void BootstrapImpl() { lock (instance) { if (this.State == RunState.Created) { string meth = "Bootstrap"; this.State = RunState.Bootstrapping; this.logger = LogManager.Instance.GetProvider(typeof(AuthenticationManager)); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(AuthenticationManager), "authenticationProvider"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { TypeNameReference typeName = TypeNameReference.Parse(tName); if (typeName != null) { param = config.Get(typeof(AuthenticationManager), "credentialProvider"); if (param != null) { tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { TypeNameReference credName = TypeNameReference.Parse(tName); if (credName != null) { this.Bootstrap(typeName, credName); return; } else { Log(meth, LogLevel.Error, "Failed to parse credential provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get credential provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get credential provider param"); } } else { Log(meth, LogLevel.Error, "Failed to parse authentication provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get authentication provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get authentication provider param"); } } else { Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider"); } this.State = RunState.FailedBootstrapping; } } }
protected override bool Initialize() { lock (instance) { if (!this.initialized) { string meth = "Initialize"; this.logger = LogManager.Instance.GetProvider(typeof(CachingPermissionProviderFactory)); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(CachingPermissionProviderFactory), "provider"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { TypeNameReference typeName = TypeNameReference.Parse(tName); if (typeName != null) { innerFact = NameReflectionUtils.CreateInstance <PermissionProviderFactory>(typeName); if (innerFact != null) { if (InitializeOther(innerFact)) { //ok preload the cache LocalSystemUser u = new LocalSystemUser(SecurityUtils.AdminIdentity, "Admin", UserState.Active); IPermissionProvider prov = this.GetProviderOther(this.innerFact, new UserSecurityContext(u)); if (prov != null) { IEnumerable <Permission> perms = prov.GetPermissions(); if (perms != null) { foreach (Permission p in perms) { PermissionMemorySet.RegisterPermission(p); } this.initialized = true; return(true); } else { Log(meth, LogLevel.Error, "Failed to get existing permissions"); } } else { Log(meth, LogLevel.Error, "Failed to get inner provider for preload"); } } else { Log(meth, LogLevel.Error, "Failed to initialize inner provider"); } } else { Log(meth, LogLevel.Error, "Failed to create inner provider factory"); } } else { Log(meth, LogLevel.Error, "Failed to parse permission provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get provider param"); } } else { Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider"); } } } return(false); }
public void Initialize() { if (this.State == RunState.Created || this.State == RunState.FailedInitializing) { this.State = RunState.Initializing; if (ConfigurationManager.Instance.State == RunState.Created) { ConfigurationManager.Instance.Bootstrap(); ConfigurationManager.Instance.Initialize(); } if (ConfigurationManager.Instance.State == RunState.Initialized) { ConfigurationManager.Instance.Start(); } if (ConfigurationManager.Instance.State == Osrs.Runtime.RunState.Running) { if (LogManager.Instance.State == RunState.Created) { LogManager.Instance.Bootstrap(); LogManager.Instance.Initialize(); } if (LogManager.Instance.State == RunState.Initialized) { LogManager.Instance.Start(); } if (LogManager.Instance.State == Osrs.Runtime.RunState.Running) { logger = LogManager.Instance.GetProvider(typeof(HostServiceProxy)); if (logger == null) { logger = new NullLogger(typeof(HostServiceProxy)); } ConfigurationProviderBase cfg = ConfigurationManager.Instance.GetProvider(); if (cfg != null) { ConfigurationParameter parm = cfg.Get(typeof(HostServiceProxy), "appListFileName"); if (parm != null) { try { this.fileName = (string)parm.Value; if (!string.IsNullOrEmpty(this.fileName)) { if (File.Exists(this.fileName)) { this.logger.Log(0, "Init(Constructor): Succeeded"); this.State = RunState.Initialized; return; } } } catch { } } } } } } }
protected override bool Initialize() { lock (this) { if (!initialized) { ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { Type myType = typeof(UserPasswordProviderFactory); ConfigurationParameter parm = config.Get(myType, "historyProvider"); if (parm != null) { TypeNameReference fact = TypeNameReference.Parse((string)parm.Value); if (fact != null) { UserPasswordConfig myConfig = new UserPasswordConfig(); myConfig.HistoryProvider = fact; parm = config.Get(myType, "maxHistory"); if (parm != null) { try { myConfig.MaxHistory = (ushort)(int)parm.Value; parm = config.Get(myType, "hashLength"); if (parm != null) { try { myConfig.HashLength = (int)parm.Value; if (myConfig.HashLength > 0) { parm = config.Get(myType, "hashMinChar"); if (parm != null) { try { myConfig.MinChar = (char)(int)parm.Value; if (myConfig.MinChar > 0) { parm = config.Get(myType, "hashMaxChar"); if (parm != null) { try { myConfig.MaxChar = (char)(int)parm.Value; if (myConfig.MaxChar > 0) { //TODO -- add complexity rule config params return(this.Initialize(myConfig)); } } catch { } } } } catch { } } } } catch { } } } catch { } } } } } } } return(false); }
public ConfigurationProviderTests() { _configurationProvider = new ConfigurationProviderLyft("appsettings.json"); }
private static IHandlerMapper InitApi(ConfigurationProviderBase prov) { string root = "api/"; VerbRestrictingMatchRule verbs = new VerbRestrictingMatchRule(HttpVerbs.GET.ToString(), HttpVerbs.POST.ToString()); UrlBaseMatchRule url = new UrlBaseMatchRule(new string[] { root }); verbs.NextMatcher = url; ServerRouting router = new ServerRouting(); SessionIdHeader head = new SessionIdHeader(); head.Next = router; MatchRuleMapHandler mapper = new MatchRuleMapHandler(head, verbs); //add all other handlers Session s = new Session(); router.Map.Add(new UrlBaseMapHandler(s, root + s.BaseUrl)); Login l = new Login(); router.Map.Add(new UrlBaseMapHandler(l, root + l.BaseUrl)); UserAuthorizations au = new UserAuthorizations(); router.Map.Add(new UrlBaseMapHandler(au, root + au.BaseUrl)); UserAffiliationHandler uah = new UserAffiliationHandler(); router.Map.Add(new UrlBaseMapHandler(uah, root + uah.BaseUrl)); Request req = new Request(); router.Map.Add(new UrlBaseMapHandler(req, root + req.BaseUrl)); OrganizationHandler orgs = new OrganizationHandler(); router.Map.Add(new UrlBaseMapHandler(orgs, root + orgs.BaseUrl)); SitesHandler sites = new SitesHandler(); router.Map.Add(new UrlBaseMapHandler(sites, root + sites.BaseUrl)); ProjectsHandler projs = new ProjectsHandler(); router.Map.Add(new UrlBaseMapHandler(projs, root + projs.BaseUrl)); FieldActivitiesHandler fas = new FieldActivitiesHandler(); router.Map.Add(new UrlBaseMapHandler(fas, root + fas.BaseUrl)); FileTransferHandler fts = new FileTransferHandler(); router.Map.Add(new UrlBaseMapHandler(fts, root + fts.BaseUrl)); InstrumentsHandler inst = new InstrumentsHandler(); router.Map.Add(new UrlBaseMapHandler(inst, root + inst.BaseUrl)); PersonsHandler per = new PersonsHandler(); router.Map.Add(new UrlBaseMapHandler(per, root + per.BaseUrl)); TaxaHandler tax = new TaxaHandler(); router.Map.Add(new UrlBaseMapHandler(tax, root + tax.BaseUrl)); WQHandler wq = new WQHandler(); router.Map.Add(new UrlBaseMapHandler(wq, root + wq.BaseUrl)); FishHandler fish = new FishHandler(); router.Map.Add(new UrlBaseMapHandler(fish, root + fish.BaseUrl)); VegetationHandler veg = new VegetationHandler(); router.Map.Add(new UrlBaseMapHandler(veg, root + veg.BaseUrl)); EntityBundlesHandler ebh = new EntityBundlesHandler(); router.Map.Add(new UrlBaseMapHandler(ebh, root + ebh.BaseUrl)); DetsHandler det = new DetsHandler(); router.Map.Add(new UrlBaseMapHandler(det, root + det.BaseUrl)); return(mapper); }
protected override bool Initialize() { lock (instance) { if (!this.initialized) { string meth = "Initialize"; this.logger = LogManager.Instance.GetProvider(typeof(CachingRoleProviderFactory)); Log(meth, LogLevel.Info, "Called"); ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider(); if (config != null) { ConfigurationParameter param = config.Get(typeof(CachingRoleProviderFactory), "provider"); if (param != null) { string tName = param.Value as string; if (!string.IsNullOrEmpty(tName)) { TypeNameReference typeName = TypeNameReference.Parse(tName); if (typeName != null) { innerFact = NameReflectionUtils.CreateInstance <RoleProviderFactory>(typeName); if (innerFact != null) { if (InitializeOther(innerFact)) { //ok preload the cache LocalSystemUser u = new LocalSystemUser(SecurityUtils.AdminIdentity, "Admin", UserState.Active); IRoleProvider prov = this.GetProviderOther(this.innerFact, new UserSecurityContext(u)); if (prov != null) { if (RoleMemorySet.Reset(prov)) { if (RoleMembershipMemorySet.Reset(prov)) { this.initialized = true; scavengeTimer = new Timer(this.Scavenge, null, 0, 300000); //5 minutes return(true); } else { Log(meth, LogLevel.Error, "Failed to initialize caching"); } } else { Log(meth, LogLevel.Error, "Failed to initialize caching"); } } else { Log(meth, LogLevel.Error, "Failed to get inner provider for preload"); } } else { Log(meth, LogLevel.Error, "Failed to initialize inner provider"); } } else { Log(meth, LogLevel.Error, "Failed to create inner provider factory"); } } else { Log(meth, LogLevel.Error, "Failed to parse permission provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get permission provider param value"); } } else { Log(meth, LogLevel.Error, "Failed to get provider param"); } } else { Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider"); } } } return(false); }
static void Init() { lock (syncRoot) { HostMessage m = new HostMessage(); m.Command = HostCommand.Init; if (state == RunState.Created) { IEnumerable <TypeNameReference> names = null; m.Message = ""; LogProviderBase log = null; try { ConfigurationManager.Instance.Bootstrap(); ConfigurationManager.Instance.Initialize(); ConfigurationManager.Instance.Start(); if (ConfigurationManager.Instance.State == RunState.Running) { LogManager.Instance.Bootstrap(); LogManager.Instance.Initialize(); LogManager.Instance.Start(); if (LogManager.Instance.State == RunState.Running) { log = LogManager.Instance.GetProvider(typeof(Program)); } if (log == null) { log = new NullLogger(typeof(Program)); } ConfigurationProviderBase prov = ConfigurationManager.Instance.GetProvider(); if (prov != null) { ConfigurationParameter param = prov.Get(typeof(Program), "hostList"); if (param != null) { string[] values = param.Value as string[]; if (values != null && values.Length > 0) { HashSet <TypeNameReference> tps = new HashSet <TypeNameReference>(); foreach (string s in values) { TypeNameReference cur = TypeNameReference.Parse(s); if (cur != null) { tps.Add(cur); } else { log.Log(5, "Failed to parse TypeName for: " + s); } } if (tps.Count > 0) { names = tps; } } else { m.Message = "Failed to get configuration value"; log.Log(1000, m.Message); } } else { m.Message = "Failed to get configuration parameter: hostList"; log.Log(1000, m.Message); } } else { m.Message = "Failed to get configuration provider"; log.Log(1000, m.Message); } } else { m.Message = "Failed to initialize using local file, quitting (" + AppContext.BaseDirectory + ")"; if (log != null) { log.Log(1000, m.Message); } } } catch { m.Message = "Failed to initialize using config, falling back to local file"; if (log != null) { log.Log(1000, m.Message); } } if (names != null) { HostingManager.Instance.Initialize(names); state = HostingManager.Instance.State; if (state == RunState.Initialized) { m.Message = "success " + m.Message; if (log != null) { log.Log(0, m.Message); } } else { m.Message = "failed " + m.Message; if (log != null) { log.Log(1000, m.Message); } } } else { state = HostingManager.Instance.State; m.Message = "failed " + m.Message; if (log != null) { log.Log(1000, m.Message); } } } else { state = HostingManager.Instance.State; m.Message = "ignored"; } comms.Send(m); } }