Reflecting on Friend Properties...

  • Thread starter Thread starter MstrControl
  • Start date Start date
M

MstrControl

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
 
MstrControl said:
Does anyone know how to retrieve a list of Frined properties?

At a guess, have you tried using the BindingFlags.NonPublic flag in your
calls to GetProperties() and GetMembers()?
 
Just a question: why not allow the child classes to, at the very most,
provide the columns they wish to retrieve using either an overridden
protected function or setting a property value? Reflection (used in
this way) is an expensive set of operations.

That being said, you just need to provide the appropriate binding flags
to the GetProperties method. Since they're binary flags, you can
specify more than one by either using + or (more generally accepted)
the "or" operator. For example,

....GetProperties(bindingflags.flag1 or bindingflags.flag2)

none of those names are right, but it should show what I mean by using
the or operator.

You should include Public, NonPublic, Instance, and whichever other
ones appeal to you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top