473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 1964
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Oriane | last post by:
Hi, I'm currently a method attribute which is used to check the "validity" of this method against a rule. I wrote the isValid method, to be used inside the otriginal method: For instance: //...
8
by: critter | last post by:
I am trying to get a value of a property of a class, but not an instance of the class. Using Reflection, I can find the class in my assembly, and I can find the property of my class, however, I...
6
by: Dave | last post by:
We have developed a few .NET components. The application access these components through well defined interface IOurInterface. The application list display name of each component in the dialog,...
7
by: Ben Amada | last post by:
I've created a class that I need to store in ViewState. However when I try to store it in ViewState, I get the following error: "The type 'solution.pe2' must be marked as Serializable or have a...
3
by: Dan Holmes | last post by:
If i have Class2 that is inherited by Class1, how can Class1's methods operate on Class2's assembly information? For instance: public class Component { public virtual List<ComponentInfo>...
1
by: Jared | last post by:
Hi I have been looking for a few hours and couldn't find much in these groups, so I thought I would post it here in case anybody else is trying to figure it out. I have an ascx User control...
1
by: chris.bahns | last post by:
Hello All, I am fairly new to creating custom attributes, and want to get a better feel for how they should be named. We have a class hierarchy, with a base class called "SequenceCommand". This...
1
by: hardieca | last post by:
Hi! I decorate my unfinished classes and methods with a custom TODO attribute (as in things To Do). Using reflection, I am then able to parse through my classes and output all TODOs to a list I...
1
by: BrendanC | last post by:
I'm trying to understand reflection/introspection in Python. How can I identify the the type of attribute (e.g. instance var) in a class? The following returns all the class attributes (methods and...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.