public static T CreateInstance <T>() where T : class { Type configObjType = typeof(T); if (typeof(ContextBoundObject).IsAssignableFrom(configObjType)) { return(ChoSingleton <T> .GetInstance(SingletonTypeValidationRules.AllowAll)); } else { if (!ChoObjectManagementFactory.IsCached(configObjType)) { //Load config file and assign values to object memebers ChoConfigurationSectionAttribute configurationElement = ChoType.GetAttribute(configObjType, typeof(ChoConfigurationSectionAttribute)) as ChoConfigurationSectionAttribute; if (configurationElement == null || configurationElement.GetMe(configObjType) == null) { throw new ChoConfigurationException(String.Format(CultureInfo.InvariantCulture, Resources.ES1001, configObjType.Name)); } return((T)configurationElement.GetMe(configObjType).Construct(configObjType)); } else { return((T)ChoObjectManagementFactory.GetObject(configObjType)); } } }
public virtual void Refresh() { if (_configurationElementAttribute == null) { return; } _configurationElementAttribute.GetMe(GetType()).Refresh(true); }
public static string GetHelpText(Type configObjectType) { if (configObjectType == null) { return(null); } if (!typeof(ChoConfigurableObject).IsAssignableFrom(configObjectType)) { return(null); } ChoConfigurationSectionAttribute configurationElementAttribute = ChoType.GetAttribute(configObjectType, typeof(ChoConfigurationSectionAttribute)) as ChoConfigurationSectionAttribute; if (configurationElementAttribute == null) { return(null); } ChoBaseConfigurationElement ele = configurationElementAttribute.GetMe(configObjectType); if (ele == null) { return(null); } return(ele.GetHelpText(configObjectType)); }
public static void RefreshConfig(object configObject) { ChoGuard.ArgumentNotNull(configObject, "Config Object."); ChoConfigurationSectionAttribute configurationElementAttribute = ChoType.GetAttribute(configObject.GetType(), typeof(ChoConfigurationSectionAttribute)) as ChoConfigurationSectionAttribute; if (configurationElementAttribute == null) { return; } configurationElementAttribute.GetMe(configObject.GetType()).Refresh(true); }