473,396 Members | 1,860 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,396 software developers and data experts.

Hiding Attributes from Reflection

Hi NG,
is there any way to hide an attribute from being reflected through PropertyInfo?
The reason for that question: I got a class with a lot of attributes which
are public and bound to the instance and I want to expose a few to an user
interface but even not all.

thanks for any help

regards
sascha
Nov 4 '06 #1
4 3025
Sascha Dietl <gi****@web.dewrote:
is there any way to hide an attribute from being reflected through PropertyInfo?
The reason for that question: I got a class with a lot of attributes which
are public and bound to the instance and I want to expose a few to an user
interface but even not all.
Could you clarify whether you're really talking about attributes, or
whether you're really talking about properties?

Do you have control over the user interface in question, by the way?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 4 '06 #2
Hello Jon,
Do you have control over the user interface in question, by the way?
i'm sorry my mistake i meant properties that i want to hide from reflection.

regards
Sascha
Nov 4 '06 #3
Sascha Dietl <Sa*********@discussions.microsoft.comwrote:
Do you have control over the user interface in question, by the way?

i'm sorry my mistake i meant properties that i want to hide from reflection.
Okay, no problem. You can't prevent the properties from being available
from reflection, but if you apply [Browsable(false)] to the property,
then the normal visual designers won't display the property. Depending
on what UI is displaying the objects, that may be good enough.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 5 '06 #4
Another option if the situation warrants...

Actually, most UI bindings don't (directly) use reflection: they use
the component model [it just happens that the default component model
implementation uses reflection].

You could implement ICustomTypeDescriptor, and return your own
PropertyDescriptor implementation (based for instance on
SimplePropertyDescriptor IIRC).

Again, it depends on the scenario - i.e. whether you need to hide
properties based on the value of other properties... but it is a viable
(and very powerful) alternative.

Marc

Nov 5 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: AlexB | last post by:
A windows forms .NET application has various built in attributes like: <Assembly: AssemblyTitle("MyAssembly")> <Assembly: AssemblyDescription("Blahblah")> <Assembly: AssemblyCompany("XYZ")> ...
12
by: Alex Hunsley | last post by:
There's no really specific questions in this post, but I'm looking for people's thought on the issues within... The two main versions I've encountered for data pseudo-hiding (encapsulation) in...
1
by: Hari | last post by:
Hello, I am quite new to C# and when reading over a couple of books discovered the presence of reflection and attributes. While, I do understand them a little, it would be great if I could know...
3
by: Phill. W | last post by:
(VB.Net 2003) I have a UserControl that exposes a number of public properties. When using this control on a.n.other Form, how can(?) I prevent the Forms Designer from adding code into...
3
by: Mark R. Dawson | last post by:
Hi all, I am trying to get custom attributes from a property. I can do this if I pass in the name of the property i.e. "Name" to the reflection methods, but if I pass in set_Name which is what...
2
by: prabhupr | last post by:
Hi Folks I was reading this article (http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on "Custom Attribute", written by Bipin. The only thing I did not understand in this article...
15
by: Jeff Mason | last post by:
Hi, I'm having a reflection brain fog here, perhaps someone can set me on the right track. I'd like to define a custom attribute to be used in a class hierarchy. What I want to do is to...
2
by: Marc Gravell | last post by:
It appears that when using the component model (or the default implementation, at least), then any duplicated attributes (e.g. from properties) are dropped. In my test, component-model outputs...
162
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.