471,338 Members | 1,297 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 1684
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Colin Fine | last post: by
8 posts views Thread by John Young | last post: by
7 posts views Thread by Jesper | last post: by
3 posts views Thread by hartley_aaron | last post: by
4 posts views Thread by Boni | last post: by
3 posts views Thread by MstrControl | last post: by
4 posts views Thread by MstrControl | last post: by
11 posts views Thread by LDD | last post: by
reply views Thread by rosydwin | last post: by

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.