Esempio n. 1
0
 public static ArgumentPropertyValue <string> StartsWith(this ArgumentPropertyValue <string> item, string pattern)
 {
     if (!item.Value.StartsWith(pattern))
     {
         throw new ArgumentException(string.Format("Parameter {0} must start with {1}", item.Name, pattern));
     }
     return(item);
 }
Esempio n. 2
0
 public static ArgumentPropertyValue <string> NotNullOrEmpty(this ArgumentPropertyValue <string> item)
 {
     if (string.IsNullOrEmpty(item.Value))
     {
         throw new ArgumentNullException(item.Name);
     }
     return(item);
 }
Esempio n. 3
0
 public static ArgumentPropertyValue <string> ShorterThan(this ArgumentPropertyValue <string> item, int limit)
 {
     if (item.Value.Length >= limit)
     {
         throw new ArgumentException(string.Format("Parameter {0} must be shorter than {1} chars", item.Name, limit));
     }
     return(item);
 }
Esempio n. 4
0
 public static ArgumentPropertyValue <T> NotNull <T>(this ArgumentPropertyValue <T> item) where T : class
 {
     if (item.Value == null)
     {
         throw new ArgumentNullException(item.Name);
     }
     return(item);
 }