Remove Class Attribute with Reflection

P

Philip Limbeck

Hi,

I am currently stuck with a problem concerning reflection.
We have to remove a Custom class attribute from an instance before
giving the instance to another subsystem. Is this possible
using Reflection ? I know one can get the Custom Attributes
by array for iteration.

Thanks in advance
 
C

Cowboy \(Gregory A. Beamer\)

One way I have seen this solved is to create a base class without the extra
server side stuff (attributes, etc.) and cast up before throwing to the
other system. This allows you to remove a variety of things that you do not
wish to expose with minimal pain.

Can you do this with reflection? Yes and no, unless I am just not being
visionary enough (which is possible). You have the option of Reflecting,
pulling values, et al, and Emiting out a new class without the items you do
not want. This takes quite a bit more coding than the base class, however,
and I would opt for the simpler solution, as it is less buggy.

If someone comes up with a different option, we might both learn from this
one. :)

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
 
G

GhostInAK

Hello Philip,

I can't conceive of a situation in which you would want toremove custom attributes..
however..
If the attribute is declared as .Inherit = False then you can create a class
which inherits from your existing class but which is not decorated by the
attribute. This of course will not work if the attribute has .Inherit =
True.

-Boo
 

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