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;
IListbool> boollist = new Listbool>();
for (int i = 0; i paramlist.Length; i++)
{
switch (paramlist[i].ToLowerInvariant())
{
case "checknameexisted":
boollist.Add(ValidationRuleHelper.ValidateInvalidCheckNameExistedValidationRule>(values[i]));
break;
case "directoryandfileexist":
boollist.Add(ValidationRuleHelper.ValidateInvalidDirectoryAndFileExistValidationRule>(values[i]));
break;
case "greaterthanzerointeger":
boollist.Add(ValidationRuleHelper.ValidateInvalidGreaterThanZeroIntegerValidationRule>(values[i]));
break;
case "numericnull":
boollist.Add(ValidationRuleHelper.ValidateInvalidNumericNullValidationRule>(values[i]));
break;
case "stringlength":
boollist.Add(ValidationRuleHelper.ValidateInvalidStringLengthValidationRule>(values[i]));
break;
case "stringnullorempty":
boollist.Add(ValidationRuleHelper.ValidateInvalidStringNullOrEmptyValidationRule>(values[i]));
break;
case "ipaddress":
boollist.Add(ValidationRuleHelper.ValidateInvalidIPAddressValidationRule>(values[i]));
break;
case "objectnull":
default:
boollist.Add(ValidationRuleHelper.ValidateInvalidObjectNullValidationRule>(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
}