コード例 #1
0
        /// <summary>
        /// Creates the type at random.
        /// </summary>
        /// <returns>The type at random.</returns>
        /// <param name="type">Type.</param>
        public static GeneticObject CreateTypeAtRandom(Type type)
        {
            if (type == typeof(GeneticInt))
            {
                return(GeneticInt.CreateAtRandom());
            }

            if (type == typeof(GeneticBool))
            {
                return(GeneticBool.CreateAtRandom());
            }

            if (type == typeof(GeneticGridDirection))
            {
                return(GeneticGridDirection.CreateAtRandom());
            }

            throw new StatementParseException(string.Format("Type: {0} is missing implementation support as a Genetic type", type));
        }
コード例 #2
0
        /// <summary>
        /// Parses the value.
        /// </summary>
        /// <returns>The value.</returns>
        /// <param name="type">Type.</param>
        /// <param name="valueString">Value string.</param>
        public static GeneticObject ParseValue(Type type, string valueString)
        {
            if (type == typeof(GeneticInt))
            {
                return(GeneticInt.FromString(valueString));
            }

            if (type == typeof(GeneticBool))
            {
                return(GeneticBool.FromString(valueString));
            }

            if (type == typeof(GeneticGridDirection))
            {
                return(GeneticGridDirection.FromString(valueString));
            }

            throw new StatementParseException(string.Format("Type: {0} is missing implementation support as a Genetic type", type));
        }