Attribute

  • Thread starter Thread starter Polo
  • Start date Start date
P

Polo

Hi,

I define a CustomAttribute

public class CustomAttribute : Attribute
{
...

public Something()
{
??? Ow can I retrieve the instance or type that host this attribute
}
}

I apply it on a class

[CustomAttribute()]
public class Test
{
}
 
AFAIK you can't. What exactly are you trying to do with this?
 
In fact I would like to create a Custom Attribute that is used in a
CustomTypeConverter to set IsReadOnly on all properties when a property of
the instance of the Class that host this attribute is true or false. (Lock
an instance)
But I think that I found a solution (In my CustomAttribute, I have a field
that define the name of the property and by reflexion i can retrieve
information)
Thank's


Sean Hederman said:
AFAIK you can't. What exactly are you trying to do with this?

Polo said:
Hi,

I define a CustomAttribute

public class CustomAttribute : Attribute
{
...

public Something()
{
??? Ow can I retrieve the instance or type that host this
attribute
}
}

I apply it on a class

[CustomAttribute()]
public class Test
{
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top