Skip to content

Instantly share code, notes, and snippets.

@derans
Created August 25, 2012 06:49
Select List Provider Attribute
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class SelectListProviderAttribute : Attribute
{
public ISelectListProvider Provider { get; private set; }
public SelectListProviderAttribute(Type providerType)
{
if (typeof(ISelectListProvider).IsAssignableFrom(providerType))
{
Provider = (ISelectListProvider) ObjectFactory.GetInstance(providerType);
}
else
{
throw new ArgumentException("Provider type must be of type ISelectListProvider", "providerType");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment