Пример #1
0
        public IModSetting ToSetting(IHasModSettings owner)
        {
            switch (Type)
            {
            case SettingType.Boolean:
                return(new BooleanModSetting(owner, Name, LoadTime, Ordering, DefaultValue.GetBoolean()));

            case SettingType.Integer:
                if ((AllowedValues == null) || (AllowedValues.Length == 0))
                {
                    return(new IntegerModSetting(owner, Name, LoadTime, Ordering, DefaultValue.GetInteger(), MinValue?.GetInteger() ?? long.MinValue, MaxValue?.GetInteger() ?? long.MaxValue));
                }
                else
                {
                    return(new IntegerListModSetting(owner, Name, LoadTime, Ordering, DefaultValue.GetInteger(), AllowedValues.Select(value => value.GetInteger())));
                }

            case SettingType.FloatingPoint:
                if ((AllowedValues == null) || (AllowedValues.Length == 0))
                {
                    return(new FloatingPointModSetting(owner, Name, LoadTime, Ordering, DefaultValue.GetFloatingPoint(), MinValue?.GetFloatingPoint() ?? decimal.MinValue, MaxValue?.GetFloatingPoint() ?? decimal.MaxValue));
                }
                else
                {
                    return(new FloatingPointListModSetting(owner, Name, LoadTime, Ordering, DefaultValue.GetFloatingPoint(), AllowedValues.Select(value => value.GetFloatingPoint())));
                }

            case SettingType.String:
                if ((AllowedValues == null) || (AllowedValues.Length == 0))
                {
                    return(new StringModSetting(owner, Name, LoadTime, Ordering, DefaultValue.GetString(), AllowEmptyValue));
                }
                else
                {
                    return(new StringListModSetting(owner, Name, LoadTime, Ordering, DefaultValue.GetString(), AllowedValues.Select(value => value.GetString())));
                }
            }

            return(null);
        }