RegistrationExtensionsAsModelBinderForTypesTLimit, TActivatorData, TRegistrationStyle Method |
Namespace: Autofac.Integration.Mvc
public static IRegistrationBuilder<TLimit, TActivatorData, TRegistrationStyle> AsModelBinderForTypes<TLimit, TActivatorData, TRegistrationStyle>( this IRegistrationBuilder<TLimit, TActivatorData, TRegistrationStyle> registration, params Type[] types ) where TActivatorData : IConcreteActivatorData where TRegistrationStyle : SingleRegistrationStyle
Exception | Condition |
---|---|
ArgumentNullException | Thrown if registration or types is . |
ArgumentException | Thrown if types is empty or contains all values. |
The declarative mechanism of registering model binders with Autofac is through use of RegisterModelBinders(ContainerBuilder, Assembly) and the ModelBinderTypeAttribute. This method is an imperative alternative.
The two mechanisms are mutually exclusive. If you register a model binder using RegisterModelBinders(ContainerBuilder, Assembly) and register the same model binder with this method, the results are not automatically merged together - standard dependency registration/resolution rules will be used to manage the conflict.
Any values provided in types will be removed prior to registration.