Use of Assembly Attributes

  • Thread starter Thread starter Shalom Shachne
  • Start date Start date
S

Shalom Shachne

We have been trying to mimic a sort of "plug-in" design with our
app. We are loading assemblies which are in the app's assembly
directory and then iterating all the Types in each Assembly to find
ones which match the plug-in loaders designated type.

I was thinking of perhaps trying to use Assembly Attributes to mark
the plugin Assembly(ies) so that we don't bother iterating the types
from other assemblies which we know wouldn't contain the "plugin".

It seems like there is a Product Info Assembly Attribute, that maybe
could be used for this purpose.

I'm not totally sure that this is a necessary or good idea. It seems
to iterate all the other assembly's types very quickly - so maybe this
is an unecessary optimization.

I would welcome any thoughts or suggestions.
 
AFAIK, the hard (i.e. slow) part is loading the assembly. So if you have
to load the assembly just to inspect the attribute, that's probably not
significantly better than just iterating over the types in the assembly.

Perhaps this would be where you'd want to use the ReflectionOnlyLoad[From]()
method.
If you do choose to use an attribute, I would implement your own attribute
specifically for the purpose, rather than reusing an existing one.

Agreed.
 
Back
Top