473,505 Members | 13,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reflecing on Friend Properties...

Greetings All...

I'm creating a BaseClass that will connect to a database and retrieve
the all the properties values from it.

So far so good. All the inherited classes retrieve it values from the
database... IF the properties are PUBLIC.

I'm using Reflection GetProperties and GetMemebers to retrieve the list
of properties of each class.

But in some classes I need that the BaseClass being able to see the
Friend properties.

Just to be on the same page... All classes are in a single Assembly,
so, it SHOULD work.

Does anyone know how to retrieve a list of Frined properties?

I know it's possible because the Class Viewer shows everything... I
just don't know how yet.

Regards,

Paulo

Jul 22 '05 #1
4 1759
MstrControl <ms*********@yahoo.com> wrote:
I'm creating a BaseClass that will connect to a database and retrieve
the all the properties values from it.

So far so good. All the inherited classes retrieve it values from the
database... IF the properties are PUBLIC.

I'm using Reflection GetProperties and GetMemebers to retrieve the list
of properties of each class.

But in some classes I need that the BaseClass being able to see the
Friend properties.

Just to be on the same page... All classes are in a single Assembly,
so, it SHOULD work.

Does anyone know how to retrieve a list of Frined properties?

I know it's possible because the Class Viewer shows everything... I
just don't know how yet.


Call the overload of GetProperties which takes a BindingFlags
parameter, and include BindingFlags.NonPublic.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 22 '05 #2
Jon,

"Jon Skeet [C# MVP]" <sk***@pobox.com> schrieb:
[Friend properties]


Call the overload of GetProperties which takes a BindingFlags
parameter, and include BindingFlags.NonPublic.


Mhm... I only made a quick check with 'GetProperty' +
'BindingFlags.NonPublic', but this didn't return the property for me...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 22 '05 #3
Herfried K. Wagner [MVP] <hi***************@gmx.at> wrote:
Call the overload of GetProperties which takes a BindingFlags
parameter, and include BindingFlags.NonPublic.


Mhm... I only made a quick check with 'GetProperty' +
'BindingFlags.NonPublic', but this didn't return the property for me...


Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 22 '05 #4
Jon,

"Jon Skeet [C# MVP]" <sk***@pobox.com> schrieb:
> Call the overload of GetProperties which takes a BindingFlags
> parameter, and include BindingFlags.NonPublic.


Mhm... I only made a quick check with 'GetProperty' +
'BindingFlags.NonPublic', but this didn't return the property for me...


Could you post a short but complete program which demonstrates the
problem?


My bad -- it seems that there was something wrong in my code. The code
below demonstrates how to determine the non-public properties including the
friend ones:

\\\
Dim f As New Foo
Dim Properties() As PropertyInfo = _
f.GetType().GetProperties( _
BindingFlags.Instance Or _
BindingFlags.NonPublic _
)
For Each pi As PropertyInfo in Properties
MsgBox(p.Name)
Next pi
..
..
..
Public Class Foo
Private m_Bar As String

Friend Property Bar() As String
Get
Return m_Bar
End Get
Set(ByVal Value As String)
m_Bar = Value
End Set
End Property
End Class
///

- or -

\\\
Dim f As New Foo
MsgBox( _
f.GetType().GetProperty( _
"Bar", _
BindingFlags.Instance Or BindingFlags.NonPublic _
).Name _
)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 22 '05 #5

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

Similar topics

2
2212
by: Colin Fine | last post by:
Now that PHP5 has proper scoping for class properties and methods, I've been looking in vain for friend classes, or wondering if there's another way to achieve this effect: class A { ...
8
1174
by: John Young | last post by:
Hi, I have a class (cGlobals.cs) which I create in my main form (frmMain). I have declared a variable at the top of my frmMain class (cGlobals gVars;). I then create an instance in my forms...
7
9802
by: Jesper | last post by:
I need to grant a class access to protected fields of another class in the way its possible in C++ with the friend keyword. However I would like to keep the class protected towards other class...
3
27228
by: hartley_aaron | last post by:
Hi, What does it mean when VS automatically adds a line like this to code of my form: Friend WithEvents Label1 As System.Windows.Forms.Label Also, I noticed a modifier property for each...
4
1984
by: Boni | last post by:
Dear all, I would like to have an access from one class to the private variables of other. But I also can't find a right sintax. The word "friend" seems to do something else, VB compiler still...
3
1748
by: MstrControl | last post by:
Greetings All... I'm creating a BaseClass that will connect to a database and retrieve the all the properties values from it. So far so good. All the inherited classes retrieve it values from...
4
253
by: MstrControl | last post by:
Greetings All... I'm creating a BaseClass that will connect to a database and retrieve the all the properties values from it. So far so good. All the inherited classes retrieve it values from...
11
1218
by: LDD | last post by:
What is the real benefit of using Properties? You can declare class variables either public/private. I'm not sure I understand the true benefit. Especially if you are reading from/writing to...
9
1645
by: Dimsion | last post by:
Hi, How do i expose all my forms and it controls to other form in the project? I want to be able to add a form and some control on it, this then be available to all other forms. form1 click...
0
7213
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
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
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
7471
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...
1
5026
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...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.