bool IValidationManager.Entityfieldsvalidation(FieldModel Field, string FieldValue) { //Type typeinfo = Type.GetType(FieldDataType); // var dataTypes = GetDatatypeInstance(); // if (dataTypes == null || !dataTypes.Any()) throw new ArgumentException("FieldDataTypeBase not found"); // var type = dataTypes.FirstOrDefault(t => t.Name.ToLower().Equals(FieldDataType.ToLower())); // if (type == null) throw new ArgumentException("Datatype not found"); // //Create an instance of the type // object obj = Activator.CreateInstance(type); bool Isvalid = true; DataTypeBase type = GetDataTypeByClientName(Field.TypeOf); // MethodInfo GetValidators = type.GetValidators(); // if (GetValidators == null) throw new ArgumentException(string.Format("Validation method not found in {0}", FieldDataType)); if (type == null) { return(true); } // throw new ArgumentException(string.Format("DataTypeBase is not found of {0}", FieldDataType)); //invoke AddMethod.NumericType if (type.DataType == DataType.Number && Field.TypeOf.ToLower() == "numerictype") { return(decimal.TryParse(FieldValue, out decimal i)); } if (type.ControlType == ControlType.DateOfBirth && !string.IsNullOrEmpty(FieldValue)) { var parsedDate = new System.DateTime(); if (System.DateTime.TryParse(FieldValue, out parsedDate)) { return(System.DateTime.Now > parsedDate); } else { return(false); } } List <ValidatorBase> validators = type.GetValidators(); // validators = (List<ValidatorBase>)GetValidators.Invoke(obj, null); if (validators == null || validators.Count == 0) { return(true); } var ValidationName = GetValidatorInstance(); List <bool> IsallValid = new List <bool>(); foreach (var v in validators) { //Type ValidationName = Type.GetType(v.ValidationName); var valitype = ValidationName.FirstOrDefault(t => t.Name.ToLower().Equals(v.ValidationName.ToLower())); if (valitype == null) { throw new ArgumentException("ValidationType not found"); } var validatortype = Activator.CreateInstance(valitype); MethodInfo IsValidators = valitype.GetMethod("IsValid"); if (IsValidators == null) { throw new ArgumentException(string.Format("Validation method not found of {0}", v.ValidationName)); } IsallValid.Add((bool)IsValidators.Invoke(validatortype, new object[] { v, FieldValue })); //if (v.ValidationName == "RangeValidator" || v.ValidationName == "LengthValidator") //{ // //Client setting validation // // end //} } if (IsallValid.Count > 0) { Isvalid = IsallValid.Contains(false) ? false : true; } return(Isvalid); }