Brett

Brett

  • NA
  • 5
  • 0

How do I?

Jan 26 2010 4:25 PM

Hello,

Basically I have this custom attribute and one of the properties in the attribute is Name for if you want to change the name of the property that the attribute is attached too. By default I want the attribute to use the name that the property already has if I they don't care to set the name. How do I do this? Do I use reflection?

   public partial class User : UserBase

    {

        [Filter()]

        public string FriendlyName { get; set; }

    }

So I want to get 'FriendlyName' and stick it into my FilterProperty:

  

   
  [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]

    public class FilterAttribute : Attribute

    {

        private bool isFilterable;

        private string filterName;


        public FilterAttribute()

        {

            isFilterable = true;

           filterName = ???

        }