0
Reply

How do I?

Brett

Brett

Jan 26 2010 4:25 PM
2.1k

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 = ???

        }