コード例 #1
0
        public override void ClearState(ValidationContext context)
        {
            if (context == null) //initialize before validating
            {
                _stateStack.Clear();
                _values = _partLevel ? new HashSet <string>(_comparer) : null;
            }
            else //unique scope element reached
            {
                if (_values != null)
                {
                    _stateStack.Push(_values);
                }

                _reg.AddCallBackMethod(context.Element, () =>
                {
                    if (_stateStack.Any())
                    {
                        _values = _stateStack.Pop();
                    }
                    else
                    {
                        _values = null;
                    }
                });

                _values = new HashSet <string>(_comparer);
            }
        }
コード例 #2
0
 public override void ClearState(ValidationContext context)
 {
     if (context == null) //initialize before validating
     {
         _stateStack.Clear();
         _values = _partLevel ? new List <string>() : null;
     }
     else //unique scope element reached
     {
         if (_values != null)
         {
             _stateStack.Push(_values);
         }
         _reg.AddCallBackMethod(context.Element, AdjustState);
         _values = new List <string>();
     }
 }