public class InvalidMultiValidationRuleToBooleanMultiConverter : IMultiValueConverter
{
#region IMultiValueConverter Members
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
string[] paramlist = ((string)parameter).Split('|');
if (paramlist == null || paramlist.Length <= 0)
{
throw new ArgumentNullException("parameter");
}
int length = paramlist.Length;
IList boollist = new List();
for (int i = 0; i < paramlist.Length; i++)
{
switch (paramlist[i].ToLowerInvariant())
{
case "checknameexisted":
boollist.Add(ValidationRuleHelper.Validate(values[i]));
break;
case "directoryandfileexist":
boollist.Add(ValidationRuleHelper.Validate(values[i]));
break;
case "greaterthanzerointeger":
boollist.Add(ValidationRuleHelper.Validate(values[i]));
break;
case "numericnull":
boollist.Add(ValidationRuleHelper.Validate(values[i]));
break;
case "stringlength":
boollist.Add(ValidationRuleHelper.Validate(values[i]));
break;
case "stringnullorempty":
boollist.Add(ValidationRuleHelper.Validate(values[i]));
break;
case "ipaddress":
boollist.Add(ValidationRuleHelper.Validate(values[i]));
break;
case "objectnull":
default:
boollist.Add(ValidationRuleHelper.Validate(values[i]));
break;
}
}
bool result = boollist[0];
for (int i = 1; i < boollist.Count; i++)
{
result = result & boollist[i];
}
return result;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
return null;
}
#endregion
}