Ejemplo n.º 1
0
        public virtual object CreateSettings(SettingEntryType settingType)
        {
            if (!FactoryFuncs.ContainsKey(settingType))
            {
                throw new InvalidOperationException("Cannot create setting of the given type");
            }

            return(FactoryFuncs[settingType]());
        }
Ejemplo n.º 2
0
        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);
        }