Created
August 25, 2012 06:49
Select List Provider Attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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