예제 #1
0
 public string?Validate()
 {
     if (string.IsNullOrWhiteSpace(Name))
     {
         return("Name must be set.");
     }
     if (string.IsNullOrWhiteSpace(Abbr))
     {
         return("Abbreviation must be set.");
     }
     if (ExpressionType == UExpressionType.Numerical)
     {
         if (Abbr.Trim().Length < 1 || Abbr.Trim().Length > 4)
         {
             return("Abbreviation must be between 1 and 4 characters long.");
         }
         if (Min >= Max)
         {
             return("Min must be smaller than max.");
         }
         if (DefaultValue < Min || DefaultValue > Max)
         {
             return("Default value must be between min and max.");
         }
     }
     else
     {
         var options = OptionValues.Split(',');
         if (options.Length < 2)
         {
             return("No options specified.");
         }
     }
     return(null);
 }
예제 #2
0
 public UExpressionDescriptor Build()
 {
     return(ExpressionType == UExpressionType.Numerical
     ? new UExpressionDescriptor(
                Name.Trim(), Abbr.Trim().ToLower(), Min, Max, DefaultValue, Flag)
     : new UExpressionDescriptor(
                Name.Trim(), Abbr.Trim().ToLower(), IsFlag, OptionValues.Split(',')));
 }