void ComputeDisplayValues()
{
if( _displayValues == null )
{
Type displayValuesType = typeof( Dictionary<,> )
.GetGenericTypeDefinition().MakeGenericType( typeof( string ), _type );
this._reverseValues = (IDictionary)Activator.CreateInstance( displayValuesType );
this._displayValues =
(IDictionary)Activator.CreateInstance( typeof( Dictionary<,> )
.GetGenericTypeDefinition()
.MakeGenericType( _type, typeof( string ) ) );
var fields = _type.GetFields( BindingFlags.Public | BindingFlags.Static );
foreach( var field in fields )
{
object enumValue = field.GetValue( null );
string displayString = GetDisplayStringValue( enumValue );
if( displayString != null )
{
_displayValues.Add( enumValue, displayString );
_reverseValues.Add( displayString, enumValue );
}
}
}
}