/// <summary> /// The method throws an Exception of type <see cref="TException" /> if the field is not valid for the Country. /// </summary> /// <typeparam name="TException"> /// Type of the Exception that will be thrown. /// </typeparam> /// <param name="country"> /// Country that contains the information to check the Field. /// </param> /// <param name="field"> /// Field to check. /// </param> /// <param name="fieldName"> /// Name of the field to check. /// </param> /// <exception> /// If the Field is not valid for the Country, an Exception of type <see cref="TException" /> will be thrown. /// </exception> protected void CheckIsValidField <TException>(ICountry country, string field, string fieldName) where TException : Exception, new() { if (!Validator.IsValid(country, field)) { throw (TException)Activator.CreateInstance(typeof(TException), string.Format( "Parameter {0} '{1}' for country '{2}' is not valid.", fieldName, field, country.Iso3166)); } }
/// <summary> /// The method throws an Exception of type <see cref="TException" /> if the Fiel is not valid. /// </summary> /// <typeparam name="TType"> /// Type of the argument. /// </typeparam> /// <typeparam name="TException"> /// Type of the exception that will be thrown. /// </typeparam> /// <param name="validator"> /// Validator that perfmorms the validation. /// </param> /// <param name="detailType"> /// Enum that defines witch detail is under evaluation. /// </param> /// <param name="country"> /// Country to perform the validation. /// </param> /// <param name="field"> /// Field to validate. /// </param> /// <param name="fieldName"> /// Name of the field to validate. /// </param> /// <exception> /// If the Field is not valid, an Exception of type <see cref="TException" /> will be thrown. /// </exception> protected static void CheckIsValidArgument <TType, TException>( IDetailValidator validator, DetailType detailType, ICountry country, string field, string fieldName) where TException : InvalidBbanDetailException { if (!validator.IsValid(country, field)) { throw (TException)Activator.CreateInstance( typeof(TException), detailType, string.Format( "Parameter '{0}' of type '{1}' is not valid.", detailType, typeof(TType).Name)); } }