Attribute question


C

CSharper

I have bunch of dll's I want to add attribute to it so that at run
time, I can find out which dll method to invoke. My current plan is to
write a custom attribute and give it to the developers to use to
decorate the methods they want me to invoke during runtime. Custom
attribute works good. But every new dll people write they need to know
about my custom attributes. Is there a predefined attribute i can use
like comments or something? All I want in the attribute for the
developers to put is just method name and its description. I am trying
to avoid custom attribute and if there is an existing one I can use, I
can document it and pass it to developers. Less coupling.

Thanks.
 
Ad

Advertisements

I

Ignacio Machin ( .NET/ C# MVP )

I have bunch of dll's I want to add attribute to it so that at run
time, I can find out which dll method to invoke. My current plan is to
write a custom attribute and give it to the developers to use to
decorate the methods they want me to invoke during runtime. Custom
attribute works good. But every new dll people write they need to know
about my custom attributes. Is there a predefined attribute i can use
like comments or something? All I want in the attribute for the
developers to put is just method name and its description. I am trying
to avoid custom attribute and if there is an existing one I can use, I
can document it and pass it to developers. Less coupling.

Thanks.

Hi,

It will be the same, they need to remember and know the "system"
attribute. The only possible advantage is that the dlls do not need to
make reference to your dll where you declare your attribute
 
C

CSharper

Hi,

It will be the same, they need to remember and know the "system"
attribute. The only possible advantage is that the dlls do not need to
make reference to your dll where you declare your attribute

What attribute can I use? I am looking for a way to not to distribute
my dll and asking everyone to use it. If I could use default
attribute, that would be great. What default attribute would be a best
fit to enter name of the method and its description?
Thanks,
 
Ad

Advertisements

C

CSharper

You can look at the attributes defined in .NET here:http://msdn.microsoft..com/en-us/library/system.attribute.aspx

Scroll down to the "Inheritance Hierarchy" section.

That said, I didn't see anything in there that looks appropriate as a  
general-purpose attribute.  And given the assumption that anyone writing  
code that targets your code will need access to your code for testing  
anyway, I don't think requiring them to reference your code so that they  
can access your custom attribute is likely to be a serious problem.

Pete

Ok then I will stay with my custom attribute logic. One side
question, there is allterante approach that i was looking at is to
have everyone follow an interface for the implementation. In this
approach all the need to know is the interface definition. Anyway, I
thought attribute is better than interface.
 

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

Top