internal void Init(ServiceLocatorSetting setting) { if (setting == null) { return; } if (setting.Container != null) { this.InitTypeAliases(setting.Container.TypeAliases); this.InitObjects(setting.Container.Objects); } }
private static IServiceLocator Setup() { var config = ConfigHelper.LoadConfigSettingFromAssemblies(typeof(ServiceLocator).Assembly, null, null, null); StartupSetting setting = null; if (config != null) { config = config["htb.devfx"]; if (config != null) { setting = ConfigSetting.ToSetting <StartupSetting>(config, "startup"); } } ServiceLocatorSetting locatorSetting = null; if (setting != null && setting.CoreSetting != null) { locatorSetting = setting.CoreSetting.ServiceLocatorSetting; } IServiceLocator instance = null; if (locatorSetting != null && !string.IsNullOrEmpty(locatorSetting.TypeName)) { var typeName = locatorSetting.TypeName; instance = (IServiceLocator)TypeHelper.CreateObject(typeName, typeof(IServiceLocator), false); } if (instance == null) { instance = new ServiceLocatorInternal(); } if (instance is IServiceLocatorInternal) { ((IServiceLocatorInternal)instance).Init(locatorSetting); } return(instance); }