public static MyColor GetColor(this MyFruit fruit)
    {
        var type       = fruit.GetType();
        var memInfo    = type.GetMember(fruit.ToString());
        var attributes = memInfo[0].GetCustomAttributes(typeof(MyFunkyAttribute), false);

        if (attributes.Length > 0)
        {
            return(((MyFunkyAttribute)attributes[0]).Color);
        }
        throw new InvalidOperationException("blah");
    }
示例#2
0
 public void SimpleEnum(MyFruit fruit)
 {
     Context.Logger.LogInformation(fruit.ToString());
 }