|
-
Sep 2nd, 2003, 05:26 AM
#1
Thread Starter
Frenzied Member
Attributes - Can they know what type they are applied to?
I have a custom class that inherits from System.ComponentModel.CategoryAttribute and I want to override the GetLocalizedString function to return a localised category other than the standard ones (Appearance, Behaviour, Data etc.)
Is it possible for an attribute to get the type name of the thing it is applied to? The reason being that the resourcemanager that returns the description and category attribute needs to know which component type it is being called to return the localised string for.
Thanks in advance,
Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
-
Sep 2nd, 2003, 06:39 AM
#2
not sure if this helps, but have you tried Type.IsSubClassOf ?
eg:
VB Code:
[COLOR=BLUE]Dim[/COLOR] objType [COLOR=BLUE]As[/COLOR] Type() = Reflection.Assembly.GetExecutingAssembly.GetTypes()
[COLOR=BLUE]Dim[/COLOR] tp [COLOR=BLUE]As[/COLOR] Type
[COLOR=BLUE]For[/COLOR] [COLOR=BLUE]Each[/COLOR] tp [COLOR=BLUE]In[/COLOR] objType
[COLOR=BLUE]If[/COLOR] tp.IsSubclassOf([COLOR=BLUE]GetType[/COLOR](Form)) [COLOR=BLUE]Then
[/COLOR] MessageBox.Show(tp.Name)
[COLOR=BLUE]End[/COLOR] [COLOR=BLUE]If
[/COLOR] [COLOR=BLUE]Next[/COLOR]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Sep 2nd, 2003, 09:49 AM
#3
I haven't found a way to do this yet either but would be interested in a way to do it.
The trouble with that, dynamic_sysop, is that the type would be the attribute instead of the object it is applied to. I think he (and I) want the type of the object that the attribute is used on.
-
Sep 2nd, 2003, 10:41 AM
#4
Thread Starter
Frenzied Member
I think he (and I) want the type of the object that the attribute is used on.
That is correct - thereby using the component's resource file to hold the descriptions and category attributes that need to be localised.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|