예제 #1
0
 /// <summary>
 /// Asserts that a given object is valid.
 /// </summary>
 /// <param name="input">The input object to validate.</param>
 /// <param name="lcid">The locale culture id to look up localized restriction messages.</param>
 public void AssertValid(object input, int lcid)
 {
     foreach (Restriction r in this)
     {
         if (!r.Validate(input))
         {
             throw new RestrictionException(RestrictionMessages.GetMessage(r, lcid, input));
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Gets the restriction message for a given input object.
        /// </summary>
        /// <param name="input">The input object to validate.</param>
        /// <param name="lcid">The locale culture id to look up localized restriction messages.</param>
        /// <returns></returns>
        public string GetRestrictionMessage(object input, int lcid)
        {
            foreach (Restriction r in this)
            {
                if (!r.Validate(input))
                {
                    return(RestrictionMessages.GetMessage(r, lcid, input));
                }
            }

            return(null);
        }