public (bool success, string possibleError) Init(object parameter, int seed)
        {
            if (parameter == null)
            {
                this.currentMode = GenerateMode.Random;
            }
            else if (parameter.GetType() == typeof(string))
            {
                var parsedParams = ParameterParser.GetParameterDictionary((string)parameter);

                if (ParameterParser.ContainsKey(parsedParams, randomAliases))
                {
                    this.currentMode = GenerateMode.Random;
                }
            }
            else
            {
                string error = ErrorMessages.UnsupportedParameterType(LongName, "Init", parameter.GetType());
                return(success : false, possibleError : error);
            }

            // Set values based on chosen GenerateMode
            if (this.currentMode == GenerateMode.Random)
            {
                this.rng = new Random(seed);
                this.GenerateFilename();
            }

            return(success : true, possibleError : "");
        }
Beispiel #2
0
        public (bool success, string possibleError) Init(object parameter, int seed)
        {
            if (parameter == null)
            {
                // If no parameters are given, then go with defaults
            }
            else if (parameter.GetType() == typeof(string))
            {
                var parsedParams = ParameterParser.GetParameterDictionary((string)parameter);

                if (ParameterParser.ContainsKey(parsedParams, startAliases))
                {
                    string potentialStartValue = ParameterParser.GetValueWithKeys(parsedParams, startAliases);
                    if (!long.TryParse(potentialStartValue, out this.currentValue))
                    {
                        return(success : false, possibleError : $"{potentialStartValue} is not a number!");
                    }
                }

                if (ParameterParser.ContainsKey(parsedParams, stepAliases))
                {
                    string potentialStepValue = ParameterParser.GetValueWithKeys(parsedParams, stepAliases);
                    if (!long.TryParse(potentialStepValue, out this.step))
                    {
                        return(success : false, possibleError : $"{potentialStepValue} is not a number!");
                    }
                }
            }
            else
            {
                return(success : false, possibleError : ErrorMessages.UnsupportedParameterType(LongName, "Init", parameter.GetType()));
            }

            return(success : true, possibleError : "");
        }