public static IServiceFactory Create() { if (singleton == null) { object serviceConfig = System.Configuration.ConfigurationManager.GetSection("serviceConfig"); ServiceConfigurationSection config = null; if (serviceConfig != null) { config = (ServiceConfigurationSection)serviceConfig; singleton = new ServiceFactory(config); } else { singleton = new ServiceFactory(null); } } return(singleton); }
private ServiceFactory(ServiceConfigurationSection config) { if (config == null) { return; } services = new Dictionary <string, object>(); foreach (ServiceConfigurationElement serviceElement in config.Services) { object obj = null; string[] values = serviceElement.Service.Split(','); string assemblyName = values[1]; Assembly ass = Assembly.Load(assemblyName); if (ass != null) { obj = ass.CreateInstance(values[0]); } if (obj != null) { services.Add(serviceElement.Key, obj); } } }