Skip to content

Instantly share code, notes, and snippets.

@tomaszkubacki
Created February 28, 2012 09:33
Show Gist options
  • Save tomaszkubacki/1931527 to your computer and use it in GitHub Desktop.
Save tomaszkubacki/1931527 to your computer and use it in GitHub Desktop.
public interface IAliasProvider {
string GetModelAlias(Type modelType);
string GetPropertyAlias(PropertyInfo propertyInfo);
}
public class DefaultAliasProvider : IAliasProvider
{
public string GetModelAlias(Type modelType)
{
var modelAliasAttr = modelType.FirstAttribute<AliasAttribute>();
return modelAliasAttr != null ? modelAliasAttr.Name : null;
}
public string GetPropertyAlias(PropertyInfo propertyInfo)
{
var aliasAttr = propertyInfo.FirstAttribute<AliasAttribute>();
return aliasAttr != null ? aliasAttr.Name : null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment