public static object GetObject(this IConfigSettingElement settingElement, string objectSettingName, bool autoInit) { var objectAlias = settingElement.GetSetting(objectSettingName); var instance = ObjectService.Current.GetOrCreateObject(objectAlias); if (autoInit && instance is ISettingInitialize) { ((ISettingInitialize)instance).Init(settingElement.ConfigSetting); } return(instance); }
public static T GetObject <T>(this IConfigSettingElement settingElement, string objectSettingName, bool autoInit, Action <T> initializer) { var objectAlias = settingElement.GetSetting(objectSettingName); var instance = ObjectService.Current.GetOrCreateObject <T>(objectAlias); if (!Equals(instance, default(T)) && initializer != null) { initializer(instance); } if (autoInit && instance is ISettingInitialize) { ((ISettingInitialize)instance).Init(settingElement.ConfigSetting); } return(instance); }
/// <summary> /// 获取配置值 /// </summary> /// <param name="settingElement">强类型配置实例</param> /// <param name="name">值名</param> /// <returns>配置值</returns> public static string GetCachedSetting(this IConfigSettingElement settingElement, string name) { return(settingElement.GetObjectContext(name, () => settingElement.GetSetting(name))); }
/// <summary> /// 获取配置值 /// </summary> /// <typeparam name="T">值类型</typeparam> /// <param name="settingElement">强类型配置实例</param> /// <returns>配置值</returns> public static T GetCachedSetting <T>(this IConfigSettingElement settingElement) { return(settingElement.GetObjectContext(typeof(IConfigSettingElement), () => settingElement.GetSetting <T>())); }
/// <summary> /// 获取配置值 /// </summary> /// <typeparam name="T">值类型</typeparam> /// <param name="settingElement">强类型配置实例</param> /// <param name="name">值名</param> /// <param name="defaultValue">值缺省值</param> /// <returns>配置值</returns> public static T GetCachedSetting <T>(this IConfigSettingElement settingElement, string name, T defaultValue) { return(settingElement.GetObjectContext(name, () => settingElement.GetSetting(name, defaultValue))); }
/// <summary> /// 获取配置值 /// </summary> /// <typeparam name="T">值类型</typeparam> /// <param name="settingElement">强类型配置实例</param> /// <returns>配置值</returns> public static T GetSetting <T>(this IConfigSettingElement settingElement) { return(settingElement.GetSetting <T>(null)); }
/// <summary> /// 获取配置值 /// </summary> /// <typeparam name="T">值类型</typeparam> /// <param name="settingElement">强类型配置实例</param> /// <param name="name">值名</param> /// <returns>配置值</returns> public static T GetSetting <T>(this IConfigSettingElement settingElement, string name) { return(settingElement.GetSetting(name, default(T))); }