468,249 Members | 1,448 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Remove Class Attribute with Reflection

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
--
Philip Limbeck
phil3k [at] gmx.net
Jun 9 '06 #1
2 1744
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!
*************************************************
"Philip Limbeck" <ph****@gmx.net> wrote in message
news:44*********************@newsreader.inode.at.. .
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
--
Philip Limbeck
phil3k [at] gmx.net

Jun 9 '06 #2
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
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

Jun 9 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by critter | last post: by
7 posts views Thread by Ben Amada | last post: by
1 post views Thread by Jared | last post: by
1 post views Thread by chris.bahns | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.