473,239 Members | 1,779 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,239 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 1745
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.