I am familiar with Generics and Generics constraints etc in C#, well at least I thought so until I seen this. I was looking at this Interface in the Fluent Validation Library and it threw me, what does this line of code mean?
public interface IValidator<in T> : IValidator, IEnumerable<IValidationRule>, IEnumerable
specifically the <in T>
snippet of code.
Here is the full interface for reference. (http://fluentvalidation.codeplex.com/SourceControl/latest#src/FluentValidation/IValidator.cs)
#region
Assembly FluentValidation.dll, v4.0.30319
#endregion
using FluentValidation.Results;
using System.Collections;
using System.Collections.Generic;
namespace FluentValidation
{
// Summary:
// Defines a validator for a particualr type.
//
// Type parameters:
// T:
public interface IValidator<in T> : IValidator, IEnumerable<IValidationRule>, IEnumerable
{
// Summary:
// Sets the cascade mode for all rules within this validator.
CascadeMode CascadeMode { get; set; }
// Summary:
// Validates the specified instance.
//
// Parameters:
// instance:
// The instance to validate
//
// Returns:
// A ValidationResult object containing any validation failures.
ValidationResult Validate(T instance);
}
}