Пример #1
0
        public ValidationResultCollection(ValidationResultCollection collection) : this()
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            ErrorCode = collection.ErrorCode;
            Flag      = collection.Flag;
            _results  = collection._results;
            UpdateResultFlagedByStrategy(collection);
        }
Пример #2
0
        public static TException ToException <TException>(this ValidationResultCollection resultCollection,
                                                          Action <TException, ValidationResultCollection> appendAction = null)
            where TException : CosmosException, new()
        {
            if (resultCollection == null)
            {
                throw new ArgumentNullException(nameof(resultCollection));
            }
            var exception = NewBasicException <TException>(resultCollection);

            appendAction?.Invoke(exception, resultCollection);
            return(exception);
        }
        /// <summary>
        /// To exception
        /// </summary>
        /// <param name="resultCollection"></param>
        /// <param name="appendAction"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static ValidationException ToException(this ValidationResultCollection resultCollection,
                                                      Action <ValidationException, ValidationResultCollection> appendAction = null)
        {
            if (resultCollection == null)
            {
                throw new ArgumentNullException(nameof(resultCollection));
            }

            var exception = CreatValidationException(resultCollection);

            appendAction?.Invoke(exception, resultCollection);

            return(exception);
        }
        /// <summary>
        /// To exception
        /// </summary>
        /// <param name="resultCollection"></param>
        /// <param name="appendAction"></param>
        /// <typeparam name="TException"></typeparam>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static TException ToException <TException>(this ValidationResultCollection resultCollection,
                                                          Action <TException, ValidationResultCollection> appendAction = null)
            where TException : CosmosException, new()
        {
            if (resultCollection == null)
            {
                throw new ArgumentNullException(nameof(resultCollection));
            }

            if (typeof(TException) == typeof(ValidationException))
            {
                return(ToException(resultCollection, (e, c) => appendAction?.Invoke(e as TException, c)) as TException);
            }

            var exception = CreateBasicException <TException>(resultCollection);

            appendAction?.Invoke(exception, resultCollection);

            return(exception);
        }
Пример #5
0
 public static void RaiseException <TException>(this ValidationResultCollection resultCollection,
                                                Action <TException, ValidationResultCollection> appendAction = null)
     where TException : CosmosException, new()
 {
     throw resultCollection.ToException(appendAction);
 }
Пример #6
0
 public static ValidationHandleOperation Handle(this ValidationResultCollection collection)
 {
     return(new ValidationHandleOperation(collection));
 }
 /// <summary>
 /// Raise exception
 /// </summary>
 /// <param name="resultCollection"></param>
 /// <param name="appendAction"></param>
 /// <exception cref="ValidationException"></exception>
 public static void RaiseException(this ValidationResultCollection resultCollection,
                                   Action <ValidationException, ValidationResultCollection> appendAction = null)
 {
     throw resultCollection.ToException(appendAction);
 }
Пример #8
0
 public ValidationHandleOperation(ValidationResultCollection collection)
 {
     _collection = collection ?? throw new ArgumentNullException(nameof(collection));
 }