public virtual object CreateSettings(SettingEntryType settingType) { if (!FactoryFuncs.ContainsKey(settingType)) { throw new InvalidOperationException("Cannot create setting of the given type"); } return(FactoryFuncs[settingType]()); }
public virtual T CreateSettings <T>(SettingEntryType settingType) where T : class { if (!FactoryFuncs.ContainsKey(settingType)) { throw new InvalidOperationException("Cannot create setting of the given type"); } var stronglyTypedSetting = FactoryFuncs[settingType]() as T; if (stronglyTypedSetting == null) { throw new InvalidOperationException("Cannot create setting of the given type"); } return(stronglyTypedSetting); }