473,407 Members | 2,326 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,407 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 1754
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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,...
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.