Beispiel #1
0
 public Setting GetSetting(string name, SettingTypes parentName)
 {
     return(db.Repository <Setting>().ReadAll()
            .Include(a => a.ParentSetting)
            .FirstOrDefault(a => a.SettingName == name &&
                            a.ParentSetting.SettingName == parentName.ToString()));
 }
        private void SetSetting(SettingTypes type, string value)
        {
            var settingItem      = new SettingItemModel(type.ToString().ToLower(), value);
            var completeSettings = new CompleteSettingsModel(settingItem);

            ScenarioCache.Store(ModelKeys.CompleteSettings, completeSettings);
            WhenTheSettingsAreAttemptedToBeSet();
            new CommonSteps().ThenTheRequestIsSuccessful();
        }
Beispiel #3
0
        public void Update(string settingName, SettingTypes parentName, string newValue)
        {
            Setting updatedItem = Read(a =>
                                       a.ParentSetting.SettingName == parentName.ToString() &&
                                       a.SettingName == settingName,
                                       a => a.ParentSetting);

            updatedItem.Value = newValue;
        }
Beispiel #4
0
        public object GetGroupSetting(SettingTypes settingTypes, object settings)
        {
            var generalSettings = db.Repository <Setting>().ReadAll()
                                  .Include(a => a.ParentSetting)
                                  .Where(a => a.ParentSetting.SettingName == settingTypes.ToString())
                                  .ToDictionary(o => o.SettingName, o => o.Value);

            foreach (var prop in settings.GetType().GetProperties())
            {
                prop.SetValue(settings, generalSettings[prop.Name]);
            }
            return(settings);
        }
        public static ISettings Build(SettingTypes settingType)
        {
            switch (settingType)
            {
            case SettingTypes.Default:
                return(new DefaultSettings());

            case SettingTypes.Test:
                return(new TestSettings());

            case SettingTypes.Free:
                return(new FreeSettings());

            default:
                throw new ArgumentOutOfRangeException(settingType.ToString() + " is not a valid settings type");
            }
        }
Beispiel #6
0
        public bool DeleteImage(string category, string settingName, string fileName)
        {
            try
            {
                Storage      storage     = Storage.GetStorage(category);
                SettingTypes settingType = SettingTypes.Default;
                if (category == StorageScope.HospitalEnvironment)
                {
                    settingType = SettingTypes.Info;
                }

                var setting = Read(a => a.SettingName == settingName &&
                                   a.ParentSetting.SettingName == settingType.ToString(),
                                   a => a.ParentSetting);
                if (setting != null)
                {
                    if (category == StorageScope.Official)
                    {
                        fileName = setting.Value;
                        storage.Delete(fileName);
                        setting.Value = "";
                    }
                    else if (category == StorageScope.HospitalEnvironment)
                    {
                        var fileArr  = setting.Value.Split(';');
                        var fileList = new List <string>(fileArr);
                        storage.Delete(fileName);
                        var newStrArr = fileList.Where(a => a != fileName).ToArray();
                        if (newStrArr.Length == 0)
                        {
                            setting.Value = "";
                        }
                        else
                        {
                            setting.Value = string.Join(";", newStrArr);
                        }
                    }
                    Save();
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Beispiel #7
0
        public Preset CreateQualityLevel(QualityLevel level)
        {
            string presetTypeName = managerType.ToString();

            presetTypeName = presetTypeName.Substring(presetTypeName.IndexOf('_') + 1);

            string presetQualityName = level.ToString();

            presetQualityName = presetQualityName[0] + presetQualityName.ToLower().Substring(1);

            string finalName = string.Format("{0} Quality {1}", presetQualityName, presetTypeName);

            Preset ql = new Preset(presetQualityName.ToLower(), finalName, managerType);

            ql.SetAllQualityLevels(level);
            presets.Add(ql);

            return(ql);
        }
Beispiel #8
0
        public Scheme(SchemeVersion version, int extendedOptionsDataVersion = 0, bool setUpDefaults = true)
        {
            Version = version;

            Settings = new Setting[SchemeTypes.NumberOfNonWeaponSettings];
            for (int i = 0; i < Settings.Length; ++i)
            {
                SettingTypes settingType = (SettingTypes)i;
                Settings[i] = new Setting(settingType.ToString(), SchemeLimits.GetSettingLimits(settingType));
            }

            int weaponsCount = version >= SchemeVersion.Armageddon2 ? SchemeTypes.NumberOfWeapons : SchemeTypes.NumberOfNonSuperWeapons;

            Weapons = new Weapon[weaponsCount];
            for (int i = 0; i < Weapons.Length; ++i)
            {
                Weapons[i] = new Weapon((WeaponTypes)i);
            }

            if (version >= SchemeVersion.Armageddon3)
            {
                int optionsCount = SchemeTypes.GetExtendedOptionsSettingsCount(extendedOptionsDataVersion);
                ExtendedOptions = new Setting[optionsCount];
                for (int i = 0; i < ExtendedOptions.Length; ++i)
                {
                    ExtendedOptionTypes extendedOption = (ExtendedOptionTypes)i;
                    ExtendedOptions[i] = new Setting(extendedOption.ToString(), SchemeLimits.GetExtendedOptionLimits(extendedOption), SchemeTypes.GetExtendedOptionSettingSize(extendedOption));
                }

                Access(ExtendedOptionTypes.DataVersion).SetValue(extendedOptionsDataVersion);
            }

            Access(SettingTypes.Version).SetValue(SchemeTypes.GetSchemeVersionNumber(version));
            Access(SettingTypes.BountyMode).SetValue(SchemeGeneratorMagicNumber);

            if (setUpDefaults)
            {
                SetUpDefaults();
            }
        }
Beispiel #9
0
        public void SetValue(string paramName, object value)
        {
            Type cType = GetTypePreset();

            FieldInfo fi = cType.GetField(paramName);

            if (fi == null)
            {
                throw new Exception(string.Format("Parameter {0} not found for preset type {1}", paramName, presetType.ToString()));
            }
            SetValue(fi, value);
        }