예제 #1
0
        /// <summary>
        /// Create a new GameData record.
        /// </summary>
        /// <param name="data"><see cref="EvaluationDataRequest"/> object that holds the details of the new GameData.</param>
        /// <returns>A <see cref="EvaluationDataResponse"/> containing the new GameData details.</returns>
        public EvaluationDataResponse Add(EvaluationDataRequest data)
        {
            if (data.Key == null)
            {
                throw new ArgumentException("No Key provided. Keys must be non-empty strings containing only alpha-numeric characters and underscores.");
            }
            if (!RegexUtil.IsAlphaNumericUnderscoreNotEmpty(data.Key))
            {
                throw new ArgumentException($"Invalid Key {data.Key}. Keys must be non-empty strings containing only alpha-numeric characters and underscores.");
            }

            var query = GetUriBuilder(ControllerPrefix).ToString();

            return(Post <EvaluationDataRequest, EvaluationDataResponse>(query, data));
        }
        public static bool IsValid(EvaluationData data, out string failure)
        {
            failure = null;

            if (!RegexUtil.IsAlphaNumericUnderscoreNotEmpty(data.Key))
            {
                failure = $"Invalid Key {data.Key}. Keys must be non-empty strings containing only alpha-numeric characters and underscores.";
            }
            else if (!ParseCheck(data))
            {
                failure = $"Invalid Value {data.Value} for EvaluationDataType {data.EvaluationDataType}";
            }

            return(failure == null);
        }