title: Custom attribute on property - Getting type and value of attributed property
body: <p>I have the following custom attribute, which can be applied on properties:</p>
  
  <pre><code>[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
  public class IdentifierAttribute : Attribute
  {
  }
  </code></pre>
  
  <p>For example:</p>
  
  <pre><code>public class MyClass
  {
      [Identifier()]
      public string Name { get; set; }
  
      public int SomeNumber { get; set; }
      public string SomeOtherProperty { get; set; }
  }
  </code></pre>
  
  <p>There will also be other classes, to which the Identifier attribute could be added to properties of different type:</p>
  
  <pre><code>public class MyOtherClass
  {
      public string Name { get; set; }
  
      [Identifier()]
      public int SomeNumber { get; set; }
  
      public string SomeOtherProperty { get; set; }
  }
  </code></pre>
  
  <p>I then need to be able to get this information in my consuming class.
  For example:</p>
  
  <pre><code>public class TestClass&lt;T&gt;
  {
      public void GetIDForPassedInObject(T obj)
      {
          var type = obj.GetType();
          //type.GetCustomAttributes(true)???
      }
  }
  </code></pre>
  
  <p>What's the best way of going about this?
  I need to get the type of the [Identifier()] field (int, string, etc...) and the actual value, obviously based on the type.</p>