title: How do I add multiple attributes to an Enum?
body: <p>I have a SQL lookup-table called <strong>ClientCreditResolutionPlanActionType</strong> that I want to convert to an <a href="/questions/tagged/enum" class="post-tag" title="show questions tagged 'enum'" rel="tag">enum</a> in <a href="/questions/tagged/c%23" class="post-tag" title="show questions tagged 'c#'" rel="tag">c#</a>.  </p>
  
  <p>Very basic request, right? Right.</p>
  
  <p>My table, now <a href="/questions/tagged/enum" class="post-tag" title="show questions tagged 'enum'" rel="tag">enum</a>, however, has several columns, or now, description properties that need to go with it:</p>
  
  <ul>
  <li>StatusIcon</li>
  <li>StatusText</li>
  <li>TypeText</li>
  </ul>
  
  <hr>
  
  <p>So I figured I could do ...</p>
  
  <pre class="lang-cs prettyprint-override"><code>namespace System.ComponentModel
  {
      class StatusIconAttribute : Attribute
      {
          public string StatusIcon;
          public StatusIconAttribute(string statusIcon) { StatusIcon = statusIcon; }
      }
  
      class StatusTextAttribute : Attribute
      {
          public string StatusText;
          public StatusTextAttribute(string statusText) { StatusText = statusText; }
      }
  
      class TypeTextAttribute : Attribute
      {
          public string TypeText;
          public TypeTextAttribute(string typeText) { TypeText = typeText; }
      }
  }
  </code></pre>
  
  <p>... in my <strong>Extensions.cs</strong> class ...</p>
  
  <pre class="lang-cs prettyprint-override"><code>public static class EnumExtensions
  {
      public static string GetStatusIcon(this Enum value)
      {
          var type = value.GetType();
  
          string name = Enum.GetName(type, value);              
          if (name == null) { return null; }
  
          var field = type.GetField(name);
          if (field == null) { return null; }
  
          var attr = Attribute.GetCustomAttribute(field, typeof(StatusIconAttribute)) as StatusIconAttribute;
          if (attr == null) { return null; }
  
          return attr.StatusIcon;
      }
  
      public static string GetStatusText(this Enum value)
      {
          var type = value.GetType();
  
          string name = Enum.GetName(type, value);              
          if (name == null) { return null; }
  
          var field = type.GetField(name);
          if (field == null) { return null; }
  
          var attr = Attribute.GetCustomAttribute(field, typeof(StatusTextAttribute)) as StatusTextAttribute;
          if (attr == null) { return null; }
  
          return attr.StatusText;
      }
  
      public static string GetTypeText(this Enum value)
      {
          var type = value.GetType();
          string name = Enum.GetName(type, value);              
  
          var type = value.GetType();
  
          string name = Enum.GetName(type, value);              
          if (name == null) { return null; }
  
          var field = type.GetField(name);
          if (field == null) { return null; }
  
          var attr = Attribute.GetCustomAttribute(field, typeof(TypeTextAttribute)) as TypeTextAttribute;
         if (attr == null) { return null; }
  
          return attr.TypeText;
      }
  }
  </code></pre>
  
  <p>... and finally in my other project use it like:</p>
  
  <pre class="lang-cs prettyprint-override"><code>namespace ClientSystemServiceLibrary.Enums
  {
      [DataContract]
      public enum ClientCreditResolutionPlanActionType
      {
          [EnumMember]
          [TypeText("New resolution plan submitted.")]
          [StatusText("New Plan")]
          [StatusIcon("star.png")]
          NewPlan = 1,
  
          [EnumMember]
          [TypeText("Resolution plan waiting on approval.")]
          [StatusText("Under Review")]
          [StatusIcon("review.png")]
          UnderReview = 2,
  
          [EnumMember]
          [TypeText("Resolution plan approved.")]
          [StatusText("Approved")]
          [StatusIcon("check.png")]
          Approved = 3,
  
          [EnumMember]
          [TypeText("Resolution plan rejected.")]
          [StatusText("Rejected")]
          [StatusIcon("cross.png")]
          Rejected = 4,
  
          [EnumMember]
          [TypeText("New resolution plan comment submitted.")]
          [StatusText("New Comment")]
          [StatusIcon("message.png")]
          NewComment = 5
      }
  }E
  </code></pre>
  
  <p>Except, what I figured was wrong, as I'm receiving these error messages:</p>
  
  <blockquote>
    <p>'System.CompenentModel.TypeTextAttribute' is inaccessible due to its protection level</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>The type or namespace name 'TypeText' could not be found (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p>Same ... for all 3.</p>