public static SpellCollection Create(string name, EnumSetting spellContainers, EnumSetting allowances,
                                         EnumSetting rarities, EnumSetting characterClasses, SaveableSelectedEnumPerEnum characterCasterTypes,
                                         EnumSetting books, RarityPerCharacterClassPerSpellContainer rarityPerCharacterClassPerSpellContainer)
    {
        SpellCollection newSpellCollection = CreateInstance <SpellCollection> ();

        if (CheckName(name) == NameCheckResult.Bad)
        {
            throw new UnityException("Spell Collection name invalid, contains invalid characters.");
        }
        if (CheckName(name) == NameCheckResult.IsDefault)
        {
            throw new UnityException("Spell Collection name invalid, name cannot start with Default");
        }

        newSpellCollection.name                  = name;
        newSpellCollection.spellContainers       = spellContainers;
        newSpellCollection.allowances            = allowances;
        newSpellCollection.rarities              = rarities;
        newSpellCollection.characterClasses      = characterClasses;
        newSpellCollection.characterCasterTypes  = characterCasterTypes;
        newSpellCollection.books                 = books;
        newSpellCollection.spellCollectionFilter = SpellCollectionFilter.CreateBlank(allowances, rarities, characterClasses, books);
        newSpellCollection.spells                = new Spell[0];

        SaveableHolder.AddSaveable(newSpellCollection);

        return(newSpellCollection);
    }
Exemplo n.º 2
0
        /// <summary>
        /// Appends a <paramref name="setting"/> in the form <code>SettingName = SettingValue</code>.
        /// The setting will be written only if the value is different from the default value in the
        /// corresponding <paramref name="parameter"/>.
        /// </summary>
        /// <param name="setting"></param>
        /// <param name="parameter"></param>
        public LoliCodeWriter AppendSetting(BlockSetting setting, BlockParameter parameter = null,
                                            int spaces = 2, bool printDefaults = false)
        {
            if (parameter == null)
            {
                AppendLine($"{setting.Name} = {GetSettingValue(setting)}", spaces);
                return(this);
            }

            var isDefaultValue = setting.FixedSetting switch
            {
                StringSetting x => x.Value == (parameter as StringParameter).DefaultValue,
                IntSetting x => x.Value == (parameter as IntParameter).DefaultValue,
                FloatSetting x => x.Value == (parameter as FloatParameter).DefaultValue,
                BoolSetting x => x.Value == (parameter as BoolParameter).DefaultValue,
                ByteArraySetting x => Compare(x.Value, (parameter as ByteArrayParameter).DefaultValue),
                ListOfStringsSetting x => Compare(x.Value, (parameter as ListOfStringsParameter).DefaultValue),
                DictionaryOfStringsSetting x =>
                Compare(x.Value?.Keys, (parameter as DictionaryOfStringsParameter).DefaultValue?.Keys) &&
                Compare(x.Value?.Values, (parameter as DictionaryOfStringsParameter).DefaultValue?.Values),
                EnumSetting x => x.Value == (parameter as EnumParameter).DefaultValue,
                _ => throw new NotImplementedException(),
            };

            if (setting.InputMode != SettingInputMode.Fixed || !isDefaultValue || printDefaults)
            {
                AppendLine($"{parameter.Name} = {GetSettingValue(setting)}", spaces);
            }

            return(this);
        }
Exemplo n.º 3
0
    public static void DrawEnumSettingIntPairing(SerializedProperty enumSettingIntPairingProp, string label)
    {
        Rect position = EditorGUILayout.GetControlRect(false, GetEnumSettingIntPairingLineCount(enumSettingIntPairingProp));

        SerializedProperty enumSettingProp = enumSettingIntPairingProp.FindPropertyRelative("enumSetting");
        SerializedProperty pairingsProp    = enumSettingIntPairingProp.FindPropertyRelative("pairings");

        EditorGUILayout.ObjectField(enumSettingProp, new GUIContent(label));
        EnumSetting enumSetting = enumSettingProp.objectReferenceValue as EnumSetting;

        if (enumSetting == null)
        {
            pairingsProp.arraySize = 0;
        }
        else
        {
            pairingsProp.arraySize = enumSetting.settings.Length;
        }

        for (int i = 0; i < pairingsProp.arraySize; i++)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(enumSetting.settings[i], GUILayout.Width(position.width * 0.8f));
            SerializedProperty elementProp = pairingsProp.GetArrayElementAtIndex(i);
            elementProp.intValue = EditorGUILayout.IntField(GUIContent.none, elementProp.intValue, GUILayout.Width(position.width * 0.2f));
            EditorGUILayout.EndHorizontal();
        }
    }
Exemplo n.º 4
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUI.BeginChangeCheck();

        EditorGUILayout.PropertyField(m_EnumSettingProp, m_EnumSettingContent);
        m_RaritiesEnumSetting = EditorGUILayout.ObjectField(m_RaritiesEnumSettingContent, m_RaritiesEnumSetting, typeof(EnumSetting), false) as EnumSetting;

        if (EditorGUI.EndChangeCheck() && m_EnumSettingProp.objectReferenceValue != null && m_RaritiesEnumSetting != null)
        {
            ClearJsonableArray(m_EnumedJsonablesProp);

            m_CharacterClassesEnumSetting = m_EnumSettingProp.objectReferenceValue as EnumSetting;
            int count = m_CharacterClassesEnumSetting.Length;
            for (int i = 0; i < count; i++)
            {
                CreateJsonableInArray(m_EnumedJsonablesProp, EnumValue.CreateBlank, m_RaritiesEnumSetting);
            }
        }

        if (m_EnumSettingProp.objectReferenceValue != null && m_RaritiesEnumSetting != null)
        {
            for (int i = 0; i < m_CharacterClassesEnumSetting.Length; i++)
            {
                SerializedProperty element = m_EnumedJsonablesProp.GetArrayElementAtIndex(i);
                GUIContent         label   = new GUIContent(m_CharacterClassesEnumSetting[i]);
                EditorGUILayout.PropertyField(element, label);
            }
        }

        serializedObject.ApplyModifiedProperties();
    }
Exemplo n.º 5
0
        void EnumMenu_DataContextChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
        {
            if (!(DataContext is EnumSetting))
            {
                return;
            }

            EnumSetting ES = DataContext as EnumSetting;

            string[] values = ES.FriendlyOptions;
            int      count  = values.Length;

            if (count == 0)
            {
                return;
            }

            string friendlyValue = ES.FriendlyValue;

            for (int i = 0; i < count; i++)
            {
                MenuItem MI = new MenuItem()
                {
                    Header = values[i], IsChecked = friendlyValue == values[i]
                };
                MI.Click += MenuItem_Click;
                Items.Add(MI);
            }

            ES.ValueChanged += ES_ValueChanged;
        }
Exemplo n.º 6
0
        protected override void initEditor()
        {
            EnumSetting      enumSetting         = (EnumSetting)setting;
            IComboBoxAdapter enumComboBoxAdapter = new EnumComboBoxAdapter <Enum>(enumSetting.EnumType, enumSetting.Translations, enumSetting.NullTranslation);

            dropDown.SetAdapterAsDataSource(enumComboBoxAdapter);
        }
    public static TChild Create(Shop shop, EnumSetting powerLevelEnum)
    {
        TChild newSpecificItemCollection = CreateInstance <TChild>();

        newSpecificItemCollection.stockAvailability = shop.GetSettlement().AvailabilityPerShopSizePerStockType[shop.size][newSpecificItemCollection.GetStockType()];
        newSpecificItemCollection.ingredient        = newSpecificItemCollection.GetIngredient(shop);
        return(newSpecificItemCollection);
    }
Exemplo n.º 8
0
    public static JsonableSelectedEnumPerEnum Create(EnumSetting enumSetting, EnumValue[] selectedEnumSettings)
    {
        JsonableSelectedEnumPerEnum selectedEnumPerEnum = CreateInstance <JsonableSelectedEnumPerEnum>();

        selectedEnumPerEnum.enumSetting     = enumSetting;
        selectedEnumPerEnum.enumedJsonables = new EnumValue[enumSetting.Length];
        return(selectedEnumPerEnum);
    }
Exemplo n.º 9
0
 protected StaticListChoiceProperty CreatePropertyFromAppSetting <TEnum>(EnumSetting <TEnum> appSetting) where TEnum : struct
 {
     object[] valueChoices = Enum.GetValues(typeof(TEnum)).Cast <object>().ToArrayEx <object>();
     return(new StaticListChoiceProperty(appSetting.Path, valueChoices, valueChoices.IndexOf <object>(appSetting.DefaultValue))
     {
         Value = appSetting.Value
     });
 }
Exemplo n.º 10
0
    public static FlagsEnumSetting Create(EnumSetting enumSetting, bool[] enumedValues)
    {
        FlagsEnumSetting newFlagEnumSetting = CreateInstance <FlagsEnumSetting>();

        newFlagEnumSetting.enumSetting  = enumSetting;
        newFlagEnumSetting.enumedValues = enumedValues;
        return(newFlagEnumSetting);
    }
    public static RarityPerCharacterClass Create(string name, EnumSetting characterClasses, EnumValue[] containerRarities)
    {
        RarityPerCharacterClass newRarityPerCharacterClass = CreateInstance <RarityPerCharacterClass>();

        newRarityPerCharacterClass.m_EnumSetting     = characterClasses;
        newRarityPerCharacterClass.m_EnumedJsonables = new EnumValue[characterClasses.Length];
        return(newRarityPerCharacterClass);
    }
Exemplo n.º 12
0
        void MenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            MenuItem    MI = sender as MenuItem;
            EnumSetting s  = (EnumSetting)DataContext;

            s.FriendlyValue = (string)MI.Header;
            SetCheck(MI);
        }
Exemplo n.º 13
0
    public static IntValuedEnum Create(EnumSetting enumSetting, int[] enumedValues)
    {
        IntValuedEnum newIntValuedEnum = CreateInstance <IntValuedEnum>();

        newIntValuedEnum.enumSetting  = enumSetting;
        newIntValuedEnum.enumedValues = enumedValues;
        return(newIntValuedEnum);
    }
Exemplo n.º 14
0
    public static SaveableSelectedEnumPerEnum Create(string name, EnumSetting enumSetting, EnumValue[] selectedEnumSettings)
    {
        SaveableSelectedEnumPerEnum newSelectedEnumPerEnum = CreateInstance <SaveableSelectedEnumPerEnum>();

        newSelectedEnumPerEnum.enumSetting          = enumSetting;
        newSelectedEnumPerEnum.selectedEnumSettings = new EnumValue[enumSetting.Length];
        return(newSelectedEnumPerEnum);
    }
 public static RarityPerCharacterClass CreateBlank(EnumSetting characterClasses, EnumSetting rarities)
 {
     EnumValue[] classRarities = new EnumValue[characterClasses.Length];
     for (int i = 0; i < classRarities.Length; i++)
     {
         classRarities[i] = EnumValue.CreateBlank(rarities);
     }
     return(Create("NAME", characterClasses, classRarities));
 }
Exemplo n.º 16
0
 public static SaveableSelectedEnumPerEnum CreateBlank(EnumSetting enumSetting, EnumSetting enumSettings)
 {
     EnumValue[] selectedEnumSettings = new EnumValue[enumSetting.Length];
     for (int i = 0; i < selectedEnumSettings.Length; i++)
     {
         selectedEnumSettings[i] = EnumValue.CreateBlank(enumSettings);
     }
     return(Create("NAME", enumSetting, selectedEnumSettings));
 }
Exemplo n.º 17
0
    public static EnumValue Create(EnumSetting enumSetting, int index)
    {
        EnumValue newEnumValue = CreateInstance <EnumValue>();

        newEnumValue.enumSetting         = enumSetting;
        newEnumValue.enumedValues        = new bool[enumSetting.Length];
        newEnumValue.enumedValues[index] = true;
        return(newEnumValue);
    }
Exemplo n.º 18
0
 public static FlagsEnumSetting CreateBlank(EnumSetting enumSetting, bool defaultValue = false)
 {
     bool[] pairings = new bool[enumSetting.Length];
     for (int i = 0; i < pairings.Length; i++)
     {
         pairings[i] = defaultValue;
     }
     return(Create(enumSetting, pairings));
 }
Exemplo n.º 19
0
    public static TItemCollectionFilter CreateBlank(EnumSetting rarities, EnumSetting books)
    {
        FloatRange costRange = FloatRange.Create();

        costRange.SetRange(float.NegativeInfinity, float.PositiveInfinity);
        FlagsEnumSetting allowedRarities = FlagsEnumSetting.CreateBlank(rarities, true);
        FlagsEnumSetting allowedBooks    = FlagsEnumSetting.CreateBlank(books, true);

        return(Create("", "", costRange, allowedRarities, allowedBooks));
    }
Exemplo n.º 20
0
    public static Spell CreateBlank(EnumSetting spellContainers, EnumSetting allowances, EnumSetting rarities, EnumSetting characterClasses,
                                    SaveableSelectedEnumPerEnum casterTypesPerCharacterClass, EnumSetting books)
    {
        JsonableSelectedEnumPerEnum containerAllowances = JsonableSelectedEnumPerEnum.CreateBlank(spellContainers, allowances);
        JsonableSelectedEnumPerEnum containerRarities   = JsonableSelectedEnumPerEnum.CreateBlank(spellContainers, rarities);
        IntValuedEnum creatorLevels = IntValuedEnum.CreateBlank(characterClasses);
        EnumValue     book          = EnumValue.CreateBlank(books);

        return(Create("NAME", containerAllowances, containerRarities, creatorLevels, book, 239, 0));
    }
Exemplo n.º 21
0
    protected override void SetupFromSplitJsonString(string[] splitJsonString)
    {
        enumSetting = EnumSetting.Load(splitJsonString[0]);

        selectedEnumSettings = new EnumValue[splitJsonString.Length - 1];
        for (int i = 0; i < selectedEnumSettings.Length; i++)
        {
            selectedEnumSettings[i] = EnumValue.CreateFromJsonString(splitJsonString[i + 1]);
        }
    }
    public static void AddToShop(Shop shop, EnumSetting powerLevelEnum)
    {
        TChild specificItemCollection = Create(shop, powerLevelEnum);

        string stockType = specificItemCollection.GetStockType();

        shop.stockTypes[stockType] = true;

        specificItemCollection.SetShopCollection(shop);
    }
Exemplo n.º 23
0
    public static int DrawEnumSettingPopup(int index, SerializedProperty enumSettingProp)
    {
        EnumSetting enumSetting = enumSettingProp.objectReferenceValue as EnumSetting;

        if (enumSetting == null)
        {
            throw new UnityException("Supplied SerializedProperty is not an EnumSetting.");
        }

        return(EditorGUILayout.Popup(index, enumSetting.settings));
    }
    protected override void SetupFromSplitJsonString(string[] splitJsonString)
    {
        name          = splitJsonString[0];
        m_EnumSetting = EnumSetting.Load(splitJsonString[1]);

        m_EnumedSaveables = new TEnumedSaveables[splitJsonString.Length - 2];
        for (int i = 0; i < m_EnumedSaveables.Length; i++)
        {
            m_EnumedSaveables[i] = Saveable <TEnumedSaveables> .Load(splitJsonString[i + 2]);
        }
    }
Exemplo n.º 25
0
    protected override void SetupFromSplitJsonString(string[] splitJsonString)
    {
        name        = splitJsonString[0];
        enumSetting = EnumSetting.Load(splitJsonString[1]);

        enumedJsonables = new TEnumedJsonables[splitJsonString.Length - 2];
        for (int i = 0; i < enumedJsonables.Length; i++)
        {
            enumedJsonables[i] = Jsonable <TEnumedJsonables> .CreateFromJsonString(splitJsonString[i + 2]);
        }
    }
    protected override void SetupFromSplitJsonString(string[] splitJsonString)
    {
        name          = splitJsonString[0];
        m_EnumSetting = EnumSetting.Load(splitJsonString[1]);

        m_EnumedValues = new TEnumedValues[splitJsonString.Length - 2];
        for (int i = 0; i < m_EnumedValues.Length; i++)
        {
            m_EnumedValues[i] = Wrapper <TEnumedValues> .CreateFromJsonString(splitJsonString[i + 2]);
        }
    }
    protected override void SetupFromSplitJsonString(string[] splitJsonString)
    {
        name              = splitJsonString[0];
        powerLevelEnum    = EnumSetting.Load(splitJsonString[1]);
        stockAvailability = IntRangePerPowerLevel.Load(splitJsonString[2]);
        ingredient        = Saveable <TIngredient> .Load(splitJsonString[3]);

        specificItems = new TSpecificItem[splitJsonString.Length - 4];
        for (int i = 0; i < specificItems.Length; i++)
        {
            specificItems[i] = SpecificItem <TSpecificItem> .CreateFromJsonString(splitJsonString[i + 4]);
        }
    }
Exemplo n.º 28
0
        public void Deserialize(ISetting setting, string serialized)
        {
            EnumSetting enumSetting = setting as EnumSetting;

            if (enumSetting == null)
            {
                return;
            }
            if (Enum.TryParse(enumSetting.EnumType, serialized, out object deserializedEnum))
            {
                setting.ObjValue = deserializedEnum;
            }
        }
Exemplo n.º 29
0
        protected StaticListChoiceProperty CreatePropertyFromAppSetting <TEnum>(EnumSetting <TEnum> appSetting, TEnum defaultValue, params object[] valueChoices) where TEnum : struct
        {
            int index = valueChoices.IndexOf <object>(defaultValue);

            if (index == -1)
            {
                ExceptionUtil.ThrowArgumentException("defaultValue");
            }
            return(new StaticListChoiceProperty(appSetting.Path, valueChoices, index)
            {
                Value = appSetting.Value
            });
        }
Exemplo n.º 30
0
    public static TQualityCollectionFilter CreateBlank(EnumSetting rarities, EnumSetting books, EnumSetting qualityTypes)
    {
        FloatRange costRange = FloatRange.Create();

        costRange.SetRange(float.NegativeInfinity, float.PositiveInfinity);
        FlagsEnumSetting allowedRarities       = FlagsEnumSetting.CreateBlank(rarities, true);
        FlagsEnumSetting allowedBooks          = FlagsEnumSetting.CreateBlank(books, true);
        FlagsEnumSetting allowedQualityTypes   = FlagsEnumSetting.CreateBlank(qualityTypes, true);
        IntRange         bonusEquivalencyRange = IntRange.Create();

        bonusEquivalencyRange.SetRange(int.MinValue, int.MaxValue);
        return(Create("", "", costRange, allowedRarities, allowedBooks, allowedQualityTypes, bonusEquivalencyRange));
    }
Exemplo n.º 31
0
        public void Setup(int defaultMaxNumberOfItemsToIndexInSingleBatch, int defaultInitialNumberOfItemsToIndexInSingleBatch)
        {
            //1024 is Lucene.net default - so if the setting is not set it will be the same as not touching Lucene's settings at all
            MaxClauseCount = new IntegerSetting(settings[Constants.MaxClauseCount], 1024);

            AllowScriptsToAdjustNumberOfSteps = new BooleanSetting(settings[Constants.AllowScriptsToAdjustNumberOfSteps], false);

            IndexAndTransformerReplicationLatencyInSec = new IntegerSetting(settings[Constants.RavenIndexAndTransformerReplicationLatencyInSec], Constants.DefaultRavenIndexAndTransformerReplicationLatencyInSec);

            PrefetchingDurationLimit = new IntegerSetting(settings[Constants.RavenPrefetchingDurationLimit], Constants.DefaultPrefetchingDurationLimit);

            BulkImportBatchTimeout = new TimeSpanSetting(settings[Constants.BulkImportBatchTimeout], TimeSpan.FromMilliseconds(Constants.BulkImportDefaultTimeoutInMs), TimeSpanArgumentType.FromParse);

            MaxConcurrentServerRequests = new IntegerSetting(settings[Constants.MaxConcurrentServerRequests], 512);

            MaxConcurrentRequestsForDatabaseDuringLoad = new IntegerSetting(settings[Constants.MaxConcurrentRequestsForDatabaseDuringLoad], 50);

            MaxSecondsForTaskToWaitForDatabaseToLoad = new IntegerSetting(settings[Constants.MaxSecondsForTaskToWaitForDatabaseToLoad], 5);

            MaxConcurrentMultiGetRequests = new IntegerSetting(settings[Constants.MaxConcurrentMultiGetRequests], 192);

            MemoryLimitForProcessing = new IntegerSetting(settings[Constants.MemoryLimitForProcessing] ?? settings[Constants.MemoryLimitForProcessing_BackwardCompatibility],
                // we allow 1 GB by default, or up to 75% of available memory on startup, if less than that is available
                Math.Min(1024, (int)(MemoryStatistics.AvailableMemoryInMb * 0.75)));

            MaxPageSize =
                new IntegerSettingWithMin(settings["Raven/MaxPageSize"], 1024, 10);

            MemoryCacheLimitMegabytes =
                new IntegerSetting(settings["Raven/MemoryCacheLimitMegabytes"], GetDefaultMemoryCacheLimitMegabytes);
            MemoryCacheExpiration =
                new TimeSpanSetting(settings["Raven/MemoryCacheExpiration"], TimeSpan.FromMinutes(60),
                                    TimeSpanArgumentType.FromSeconds);
            MemoryCacheLimitPercentage =
                new IntegerSetting(settings["Raven/MemoryCacheLimitPercentage"], 0 /* auto size */);
            MemoryCacheLimitCheckInterval =
                new TimeSpanSetting(settings["Raven/MemoryCacheLimitCheckInterval"], MemoryCache.Default.PollingInterval,
                                    TimeSpanArgumentType.FromParse);

            PrewarmFacetsSyncronousWaitTime =
                new TimeSpanSetting(settings["Raven/PrewarmFacetsSyncronousWaitTime"], TimeSpan.FromSeconds(3),
                                    TimeSpanArgumentType.FromParse);

            PrewarmFacetsOnIndexingMaxAge =
                new TimeSpanSetting(settings["Raven/PrewarmFacetsOnIndexingMaxAge"], TimeSpan.FromMinutes(10),
                                    TimeSpanArgumentType.FromParse);


            MaxProcessingRunLatency =
                new TimeSpanSetting(settings["Raven/MaxProcessingRunLatency"] ?? settings["Raven/MaxIndexingRunLatency"], TimeSpan.FromMinutes(5),
                                    TimeSpanArgumentType.FromParse);
            MaxIndexWritesBeforeRecreate =
                new IntegerSetting(settings["Raven/MaxIndexWritesBeforeRecreate"], 256 * 1024);
            MaxSimpleIndexOutputsPerDocument =
                new IntegerSetting(settings["Raven/MaxSimpleIndexOutputsPerDocument"], 15);

            MaxMapReduceIndexOutputsPerDocument =
                new IntegerSetting(settings["Raven/MaxMapReduceIndexOutputsPerDocument"], 50);

            MaxNumberOfItemsToProcessInSingleBatch =
                new IntegerSettingWithMin(settings["Raven/MaxNumberOfItemsToProcessInSingleBatch"] ?? settings["Raven/MaxNumberOfItemsToIndexInSingleBatch"],
                                          defaultMaxNumberOfItemsToIndexInSingleBatch, 128);
            AvailableMemoryForRaisingBatchSizeLimit =
                new IntegerSetting(settings["Raven/AvailableMemoryForRaisingBatchSizeLimit"] ?? settings["Raven/AvailableMemoryForRaisingIndexBatchSizeLimit"],
                                   Math.Min(768, MemoryStatistics.TotalPhysicalMemory / 2));
            MaxNumberOfItemsToReduceInSingleBatch =
                new IntegerSettingWithMin(settings["Raven/MaxNumberOfItemsToReduceInSingleBatch"],
                                          defaultMaxNumberOfItemsToIndexInSingleBatch / 2, 128);
            NumberOfItemsToExecuteReduceInSingleStep =
                new IntegerSetting(settings["Raven/NumberOfItemsToExecuteReduceInSingleStep"], 1024);
            MaxNumberOfParallelProcessingTasks =
                new IntegerSettingWithMin(settings["Raven/MaxNumberOfParallelProcessingTasks"] ?? settings["Raven/MaxNumberOfParallelIndexTasks"], Environment.ProcessorCount, 1);

            NewIndexInMemoryMaxTime =
                new TimeSpanSetting(settings["Raven/NewIndexInMemoryMaxTime"], TimeSpan.FromMinutes(15), TimeSpanArgumentType.FromParse);
            NewIndexInMemoryMaxMb =
                new MultipliedIntegerSetting(new IntegerSettingWithMin(settings["Raven/NewIndexInMemoryMaxMB"], 64, 1), 1024 * 1024);
            RunInMemory =
                new BooleanSetting(settings[Constants.RunInMemory], false);
            CreateAutoIndexesForAdHocQueriesIfNeeded =
                new BooleanSetting(settings["Raven/CreateAutoIndexesForAdHocQueriesIfNeeded"], true);
            ResetIndexOnUncleanShutdown =
                new BooleanSetting(settings["Raven/ResetIndexOnUncleanShutdown"], false);
            DisableInMemoryIndexing =
                new BooleanSetting(settings["Raven/DisableInMemoryIndexing"], false);
            WorkingDir =
                new StringSetting(settings["Raven/WorkingDir"], @"~\");
            DataDir =
                new StringSetting(settings["Raven/DataDir"], @"~\Databases\System");
            IndexStoragePath =
                new StringSetting(settings["Raven/IndexStoragePath"], (string)null);
            CountersDataDir =
                new StringSetting(settings["Raven/Counters/DataDir"], @"~\Data\Counters");

            HostName =
                new StringSetting(settings["Raven/HostName"], (string)null);
            Port =
                new StringSetting(settings["Raven/Port"], "*");
            ExposeConfigOverTheWire =
                new StringSetting(settings[Constants.ExposeConfigOverTheWire], "Open");
            HttpCompression =
                new BooleanSetting(settings["Raven/HttpCompression"], true);
            AccessControlAllowOrigin =
                new StringSetting(settings["Raven/AccessControlAllowOrigin"], (string)null);
            AccessControlMaxAge =
                new StringSetting(settings["Raven/AccessControlMaxAge"], "1728000" /* 20 days */);
            AccessControlAllowMethods =
                new StringSetting(settings["Raven/AccessControlAllowMethods"], "PUT,PATCH,GET,DELETE,POST");
            AccessControlRequestHeaders =
                new StringSetting(settings["Raven/AccessControlRequestHeaders"], (string)null);
            RedirectStudioUrl =
                new StringSetting(settings["Raven/RedirectStudioUrl"], (string)null);
            DisableDocumentPreFetching =
                new BooleanSetting(settings["Raven/DisableDocumentPreFetching"] ?? settings["Raven/DisableDocumentPreFetchingForIndexing"], false);
            MaxNumberOfItemsToPreFetch =
                new IntegerSettingWithMin(settings["Raven/MaxNumberOfItemsToPreFetch"] ?? settings["Raven/MaxNumberOfItemsToPreFetchForIndexing"],
                                          defaultMaxNumberOfItemsToIndexInSingleBatch, 128);
            WebDir =
                new StringSetting(settings["Raven/WebDir"], GetDefaultWebDir);
            PluginsDirectory =
                new StringSetting(settings["Raven/PluginsDirectory"], @"~\Plugins");
            AssembliesDirectory =
                new StringSetting(settings["Raven/AssembliesDirectory"], @"~\Assemblies");
            EmbeddedFilesDirectory =
                new StringSetting(settings["Raven/EmbeddedFilesDirectory"], (string)null);
            CompiledIndexCacheDirectory =
                new StringSetting(settings["Raven/CompiledIndexCacheDirectory"], @"~\CompiledIndexCache");
            TaskScheduler =
                new StringSetting(settings["Raven/TaskScheduler"], (string)null);
            AllowLocalAccessWithoutAuthorization =
                new BooleanSetting(settings["Raven/AllowLocalAccessWithoutAuthorization"], false);
            RejectClientsModeEnabled =
                new BooleanSetting(settings[Constants.RejectClientsModeEnabled], false);

            MaxIndexCommitPointStoreTimeInterval =
                new TimeSpanSetting(settings["Raven/MaxIndexCommitPointStoreTimeInterval"], TimeSpan.FromMinutes(5),
                                    TimeSpanArgumentType.FromParse);
            MaxNumberOfStoredCommitPoints =
                new IntegerSetting(settings["Raven/MaxNumberOfStoredCommitPoints"], 5);
            MinIndexingTimeIntervalToStoreCommitPoint =
                new TimeSpanSetting(settings["Raven/MinIndexingTimeIntervalToStoreCommitPoint"], TimeSpan.FromMinutes(1),
                                    TimeSpanArgumentType.FromParse);

            TimeToWaitBeforeRunningIdleIndexes = new TimeSpanSetting(settings["Raven/TimeToWaitBeforeRunningIdleIndexes"], TimeSpan.FromMinutes(10), TimeSpanArgumentType.FromParse);

            DatbaseOperationTimeout = new TimeSpanSetting(settings["Raven/DatabaseOperationTimeout"], TimeSpan.FromMinutes(5), TimeSpanArgumentType.FromParse);

            TimeToWaitBeforeMarkingAutoIndexAsIdle = new TimeSpanSetting(settings["Raven/TimeToWaitBeforeMarkingAutoIndexAsIdle"], TimeSpan.FromHours(1), TimeSpanArgumentType.FromParse);

            TimeToWaitBeforeMarkingIdleIndexAsAbandoned = new TimeSpanSetting(settings["Raven/TimeToWaitBeforeMarkingIdleIndexAsAbandoned"], TimeSpan.FromHours(72), TimeSpanArgumentType.FromParse);

            TimeToWaitBeforeRunningAbandonedIndexes = new TimeSpanSetting(settings["Raven/TimeToWaitBeforeRunningAbandonedIndexes"], TimeSpan.FromHours(3), TimeSpanArgumentType.FromParse);

            DisableClusterDiscovery = new BooleanSetting(settings["Raven/DisableClusterDiscovery"], false);

            TurnOffDiscoveryClient = new BooleanSetting(settings["Raven/TurnOffDiscoveryClient"], false);

            ServerName = new StringSetting(settings["Raven/ServerName"], (string)null);

            MaxStepsForScript = new IntegerSetting(settings["Raven/MaxStepsForScript"], 10 * 1000);
            AdditionalStepsForScriptBasedOnDocumentSize = new IntegerSetting(settings["Raven/AdditionalStepsForScriptBasedOnDocumentSize"], 5);

            MaxRecentTouchesToRemember = new IntegerSetting(settings["Raven/MaxRecentTouchesToRemember"], 1024);

            Prefetcher.FetchingDocumentsFromDiskTimeoutInSeconds = new IntegerSetting(settings["Raven/Prefetcher/FetchingDocumentsFromDiskTimeout"], 5);
            Prefetcher.MaximumSizeAllowedToFetchFromStorageInMb = new IntegerSetting(settings["Raven/Prefetcher/MaximumSizeAllowedToFetchFromStorage"], 256);

            Voron.MaxBufferPoolSize = new IntegerSetting(settings[Constants.Voron.MaxBufferPoolSize], 4);
            Voron.InitialFileSize = new NullableIntegerSetting(settings[Constants.Voron.InitialFileSize], (int?)null);
            Voron.MaxScratchBufferSize = new IntegerSetting(settings[Constants.Voron.MaxScratchBufferSize], 6144);

            var maxScratchBufferSize = Voron.MaxScratchBufferSize.Value;
            var scratchBufferSizeNotificationThreshold = -1;
            if (maxScratchBufferSize > 1024)
                scratchBufferSizeNotificationThreshold = 1024;
            else if (maxScratchBufferSize > 512)
                scratchBufferSizeNotificationThreshold = 512;
            Voron.ScratchBufferSizeNotificationThreshold = new IntegerSetting(settings[Constants.Voron.ScratchBufferSizeNotificationThreshold], scratchBufferSizeNotificationThreshold);

            Voron.AllowIncrementalBackups = new BooleanSetting(settings[Constants.Voron.AllowIncrementalBackups], false);
            Voron.AllowOn32Bits = new BooleanSetting(settings[Constants.Voron.AllowOn32Bits], false);
            Voron.TempPath = new StringSetting(settings[Constants.Voron.TempPath], (string)null);

            var txJournalPath = settings[Constants.RavenTxJournalPath];
            var esentLogsPath = settings[Constants.RavenEsentLogsPath];

            Voron.JournalsStoragePath = new StringSetting(string.IsNullOrEmpty(txJournalPath) ? esentLogsPath : txJournalPath, (string)null);

            Esent.JournalsStoragePath = new StringSetting(string.IsNullOrEmpty(esentLogsPath) ? txJournalPath : esentLogsPath, (string)null);

            var defaultCacheSize = Environment.Is64BitProcess ? Math.Min(1024, (MemoryStatistics.TotalPhysicalMemory / 4)) : 256;
            Esent.CacheSizeMax = new IntegerSetting(settings[Constants.Esent.CacheSizeMax], defaultCacheSize);
            Esent.MaxVerPages = new IntegerSetting(settings[Constants.Esent.MaxVerPages], 512);
            Esent.PreferredVerPages = new IntegerSetting(settings[Constants.Esent.PreferredVerPages], 472);
            Esent.DbExtensionSize = new IntegerSetting(settings[Constants.Esent.DbExtensionSize], 8);
            Esent.LogFileSize = new IntegerSetting(settings[Constants.Esent.LogFileSize], 64);
            Esent.LogBuffers = new IntegerSetting(settings[Constants.Esent.LogBuffers], 8192);
            Esent.MaxCursors = new IntegerSetting(settings[Constants.Esent.MaxCursors], 2048);
            Esent.CircularLog = new BooleanSetting(settings[Constants.Esent.CircularLog], true);

            Replication.FetchingFromDiskTimeoutInSeconds = new IntegerSetting(settings["Raven/Replication/FetchingFromDiskTimeout"], 30);
            Replication.ReplicationRequestTimeoutInMilliseconds = new IntegerSetting(settings["Raven/Replication/ReplicationRequestTimeout"], 60 * 1000);
            Replication.ForceReplicationRequestBuffering = new BooleanSetting(settings["Raven/Replication/ForceReplicationRequestBuffering"], false);
            Replication.MaxNumberOfItemsToReceiveInSingleBatch = new NullableIntegerSettingWithMin(settings["Raven/Replication/MaxNumberOfItemsToReceiveInSingleBatch"], (int?)null, 512);

            FileSystem.MaximumSynchronizationInterval = new TimeSpanSetting(settings[Constants.FileSystem.MaximumSynchronizationInterval], TimeSpan.FromSeconds(60), TimeSpanArgumentType.FromParse);
            FileSystem.IndexStoragePath = new StringSetting(settings[Constants.FileSystem.IndexStorageDirectory], string.Empty);
            FileSystem.DataDir = new StringSetting(settings[Constants.FileSystem.DataDirectory], @"~\FileSystems");
            FileSystem.DefaultStorageTypeName = new StringSetting(settings[Constants.FileSystem.Storage], string.Empty);
            FileSystem.PreventSchemaUpdate = new BooleanSetting(settings[Constants.FileSystem.PreventSchemaUpdate], false);
            Encryption.UseFips = new BooleanSetting(settings["Raven/Encryption/FIPS"], false);
            Encryption.EncryptionKeyBitsPreference = new IntegerSetting(settings[Constants.EncryptionKeyBitsPreferenceSetting], Constants.DefaultKeySizeToUseInActualEncryptionInBits);
            Encryption.UseSsl = new BooleanSetting(settings["Raven/UseSsl"], false);

            Indexing.MaxNumberOfItemsToProcessInTestIndexes = new IntegerSetting(settings[Constants.MaxNumberOfItemsToProcessInTestIndexes], 512);
            Indexing.DisableIndexingFreeSpaceThreshold = new IntegerSetting(settings[Constants.Indexing.DisableIndexingFreeSpaceThreshold], 2048);
            Indexing.DisableMapReduceInMemoryTracking = new BooleanSetting(settings[Constants.Indexing.DisableMapReduceInMemoryTracking], false);

            DefaultStorageTypeName = new StringSetting(settings["Raven/StorageTypeName"] ?? settings["Raven/StorageEngine"], string.Empty);

            FlushIndexToDiskSizeInMb = new IntegerSetting(settings["Raven/Indexing/FlushIndexToDiskSizeInMb"], 5);

            TombstoneRetentionTime = new TimeSpanSetting(settings["Raven/TombstoneRetentionTime"], TimeSpan.FromDays(14), TimeSpanArgumentType.FromParse);

            ImplicitFetchFieldsFromDocumentMode = new EnumSetting<ImplicitFetchFieldsMode>(settings["Raven/ImplicitFetchFieldsFromDocumentMode"], ImplicitFetchFieldsMode.Enabled);

            if (settings["Raven/MaxServicePointIdleTime"] != null)
                ServicePointManager.MaxServicePointIdleTime = Convert.ToInt32(settings["Raven/MaxServicePointIdleTime"]);

            WebSockets.InitialBufferPoolSize = new IntegerSetting(settings["Raven/WebSockets/InitialBufferPoolSize"], 128 * 1024);

            MaxConcurrentResourceLoads = new IntegerSetting(settings[Constants.RavenMaxConcurrentResourceLoads], 8);
            ConcurrentResourceLoadTimeout = new TimeSpanSetting(settings[Constants.ConcurrentResourceLoadTimeout],
                TimeSpan.FromSeconds(15),
                TimeSpanArgumentType.FromParse);

            CacheDocumentsInMemory = new BooleanSetting(settings["Raven/CacheDocumentsInMemory"], true);
        }