Example #1
0
        internal void UpdateAsyncErrors(ScalarAsyncValidator scalarAsyncValidator)
        {
            var sourceScalars = scalarAsyncValidator.SourceScalars;

            _asyncErrors = Remove(_asyncErrors, x => x.Source.SetEquals(sourceScalars));
            _asyncErrors = Merge(_asyncErrors, scalarAsyncValidator.Results);
        }
Example #2
0
 IScalarAsyncValidators IScalarAsyncValidators.Add(ScalarAsyncValidator value)
 {
     if (value == null)
     {
         throw new ArgumentNullException(nameof(value));
     }
     return(ScalarAsyncValidators.New(this, value));
 }
Example #3
0
            public IScalarAsyncValidators Add(ScalarAsyncValidator value)
            {
                if (value == null)
                {
                    throw new ArgumentNullException(nameof(value));
                }

                return(value);
            }
Example #4
0
 /// <summary>
 /// Adds async scalar validator.
 /// </summary>
 /// <param name="sourceScalars">The source scalar data.</param>
 /// <param name="validator">Delegate to perform validation.</param>
 /// <param name="displayName">The display name used for fault error message.</param>
 /// <returns>This template builder for fluent coding.</returns>
 public T AddAsyncValidator(IScalars sourceScalars, Func <Task <IEnumerable <string> > > validator, string displayName)
 {
     if (sourceScalars == null || sourceScalars.Count == 0)
     {
         throw new ArgumentNullException(nameof(sourceScalars));
     }
     if (validator == null)
     {
         throw new ArgumentNullException(nameof(validator));
     }
     Template.AddAsyncValidator(ScalarAsyncValidator.Create(displayName, sourceScalars, validator));
     return((T)this);
 }
Example #5
0
            public IScalarAsyncValidators Add(ScalarAsyncValidator value)
            {
                if (value == null)
                {
                    throw new ArgumentNullException(nameof(value));
                }

                if (!IsSealed)
                {
                    _list.Add(value);
                    return(this);
                }

                Debug.Assert(Count > 0);
                var result = new KeyedScalarAsyncValidators();

                for (int i = 0; i < Count; i++)
                {
                    result.Add(this[i]);
                }
                result.Add(value);
                return(result);
            }
Example #6
0
 public KeyedScalarAsyncValidators(ScalarAsyncValidator value1, ScalarAsyncValidator value2)
 {
     Debug.Assert(value1 != null && value2 != null);
     Add(value1);
     Add(value2);
 }
Example #7
0
 internal static IScalarAsyncValidators New(ScalarAsyncValidator value1, ScalarAsyncValidator value2)
 {
     Debug.Assert(value1 != null && value2 != null && value1 != value2);
     return(new KeyedScalarAsyncValidators(value1, value2));
 }