private static void PrintOutNameAndConnection(XmlApplicationContext ctx) { foreach (var name in ctx.GetObjectNamesForType(typeof(MyService))) { var svc = (MyService)ctx.GetObject(name); Console.WriteLine("{0} : {1}", name, svc.Connection); } }
//TODO GetDbProviderClasses private static void InitializeDbProviderFactoryIfNeeded() { if (ctx == null) { lock (typeof(DbProviderFactory)) { if (ctx == null) { try { //TODO get from well know location in app.config.... ConfigurableResourceLoader loader = new ConfigurableResourceLoader(DBPROVIDER_ADDITIONAL_RESOURCE_NAME); if (loader.GetResource(DBPROVIDER_ADDITIONAL_RESOURCE_NAME).Exists) { #region Instrumentation if (log.IsDebugEnabled) { log.Debug("Loading additional DbProviders from " + DBPROVIDER_ADDITIONAL_RESOURCE_NAME); } #endregion ctx = new XmlApplicationContext(DBPROVIDER_CONTEXTNAME, true, new string[] { DBPROVIDER_DEFAULT_RESOURCE_NAME, DBPROVIDER_ADDITIONAL_RESOURCE_NAME }); } else { ctx = new XmlApplicationContext(DBPROVIDER_CONTEXTNAME, true, new string[] { DBPROVIDER_DEFAULT_RESOURCE_NAME }); } string[] dbProviderNames = ctx.GetObjectNamesForType(typeof(IDbProvider)); if (log.IsInfoEnabled) { log.Info(String.Format("{0} DbProviders Available. [{1}]", dbProviderNames.Length, StringUtils.ArrayToCommaDelimitedString(dbProviderNames))); } } catch (Exception e) { log.Error("Error processing " + DBPROVIDER_DEFAULT_RESOURCE_NAME, e); throw; } } } } }