/// <summary> /// Creates an instance of <see cref="Data.IValidator" /> from an <see cref="FluentValidation.AbstractValidator{T}" /> type implementation. /// </summary> /// <param name="validatorType"><see cref="FluentValidation.IValidator" /> type implementation.</param> /// <returns>An instance of <see cref="FluentValidatorToCatelValidatorAdapter" />.</returns> /// <exception cref="ArgumentNullException">The <paramref name="validatorType" /> is <c>null</c>.</exception> /// <exception cref="ArgumentException">The <paramref name="validatorType" /> is not of type <see cref="IValidator" />.</exception> /// <exception cref="ArgumentNullException">The <paramref name="validatorType" /> is <c>null</c>.</exception> /// <exception cref="ArgumentException">The <paramref name="validatorType" /> is not of type <see cref="IValidator" />.</exception> internal static Data.IValidator From(Type validatorType) { Argument.IsNotNull("validatorType", validatorType); Argument.IsOfType("validatorType", validatorType, typeof(IValidator)); return(new FluentValidatorToCatelValidatorAdapter(validatorType)); }
/// <summary> /// Converts a specific enum value from one specific enum type to another enum type by it's name. /// <para/> /// For example, to convert <c>Catel.Services.CameraType</c> to <c>Microsoft.Devices.CameraType</c>, use the /// following code: /// <para/> /// ConvertEnum<Microsoft.Devices.CameraType>(Catel.Services.CameraType.Primary); /// </summary> /// <param name="inputEnumValue">The input enum value.</param> /// <returns>The converted enum value.</returns> /// <exception cref="ArgumentNullException">The <paramref name="inputEnumValue"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">The <paramref name="inputEnumValue"/> is not of type <see cref="Enum"/>.</exception> /// <exception cref="ArgumentException">The value of <paramref name="inputEnumValue"/> cannot be converted to a value of <typeparamref name="TEnum"/>.</exception> public static TEnum ConvertFromOtherEnumValue(object inputEnumValue) { Argument.IsNotNull("inputEnumValue", inputEnumValue); Argument.IsOfType("inputEnumValue", inputEnumValue, typeof(Enum)); string value = inputEnumValue.ToString(); return((TEnum)Enum.Parse(typeof(TEnum), value, true)); }