473,425 Members | 1,715 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,425 software developers and data experts.

is it possible to get delegates from properties directly?

PJ6
I would like to refer to properties in code without having to resort to
using a string for the name. AddessOf gives me this ability for methods, but
I can't find a single way to point that at the Get or Set methods of
properties directly.

Why don't I want to use a string? Well, I want to know at design time that
my property references aren't broken, much the same way I can have this when
using regular delegates.

Is this possible?

Paul
Jun 11 '06 #1
6 1398
Hi,

You should take a look at generics in vb 2005.

http://msdn2.microsoft.com/en-us/library/ms172192.aspx

Ken
-----------------------
"PJ6" <no***@nowhere.net> wrote in message
news:Om**************@TK2MSFTNGP05.phx.gbl...
I would like to refer to properties in code without having to resort to
using a string for the name. AddessOf gives me this ability for methods,
but I can't find a single way to point that at the Get or Set methods of
properties directly.

Why don't I want to use a string? Well, I want to know at design time that
my property references aren't broken, much the same way I can have this
when using regular delegates.

Is this possible?

Paul

Jun 11 '06 #2
PJ6
Unfortunately that has nothing to do with getting at the Set and Get methods
in a Property without first having to get the ProperyInfo with a string
representing its name...

Or am I not understanding how to apply that information to my question?

Thanks,
Paul

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:u3**************@TK2MSFTNGP05.phx.gbl...
Hi,

You should take a look at generics in vb 2005.

http://msdn2.microsoft.com/en-us/library/ms172192.aspx

Ken
-----------------------
"PJ6" <no***@nowhere.net> wrote in message
news:Om**************@TK2MSFTNGP05.phx.gbl...
I would like to refer to properties in code without having to resort to
using a string for the name. AddessOf gives me this ability for methods,
but I can't find a single way to point that at the Get or Set methods of
properties directly.

Why don't I want to use a string? Well, I want to know at design time
that my property references aren't broken, much the same way I can have
this when using regular delegates.

Is this possible?

Paul


Jun 12 '06 #3
Paul,

Are you sure that VBNet is the right program language for you.

Using addresspointers to references is maybe for some a nice way of
programming, it is in my idea a litle bit out of sense to base your complete
system on it. Like an API it is a nice way to escape as nothing seems to be
more possible, to use in general is in my idea a little bit crazy.

What you see is that where it is needed, that need is often eliminiated in
the next version.

Is C++ not a better language for you?

Cor

"PJ6" <no***@nowhere.net> schreef in bericht
news:Oa**************@TK2MSFTNGP02.phx.gbl...
Unfortunately that has nothing to do with getting at the Set and Get
methods in a Property without first having to get the ProperyInfo with a
string representing its name...

Or am I not understanding how to apply that information to my question?

Thanks,
Paul

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:u3**************@TK2MSFTNGP05.phx.gbl...
Hi,

You should take a look at generics in vb 2005.

http://msdn2.microsoft.com/en-us/library/ms172192.aspx

Ken
-----------------------
"PJ6" <no***@nowhere.net> wrote in message
news:Om**************@TK2MSFTNGP05.phx.gbl...
I would like to refer to properties in code without having to resort to
using a string for the name. AddessOf gives me this ability for methods,
but I can't find a single way to point that at the Get or Set methods of
properties directly.

Why don't I want to use a string? Well, I want to know at design time
that my property references aren't broken, much the same way I can have
this when using regular delegates.

Is this possible?

Paul



Jun 12 '06 #4
PJ6
Cor,

The reason for my desire to get pointers from property methods without using
strings is simple, and that is the holding to the principle of code
normalization. In my grid, when I want to point a column to a property in
code, I don't want to have to write out the property name with a string such
as "SomeProperty". This is wrong because there is no design-time
verification that the string is correct, and if I manage to change the
property name later, or I've misspelled it, I will have no idea that
something is broken until something fails at runtime. Put more simply, I
want design-time validation of property references. Why do you think that's
crazy?

What surprises me is that I apparently cannot generate a pointer to the
property Set and Get methods the same way I can for normal methods. For
normal methods, this isn't an issue at all, I don't need to spell the method
name out in a string to get at it for use as a delegate.

Yes. Apparently this is currently a deficiency in the Framework since no one
has chimed in to say otherwise. But I'm not going to throw my hands up in
the air and compromise my design or move to C just because I run into a
limitation like this; I will look for a way around it.

Paul

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Paul,

Are you sure that VBNet is the right program language for you.

Using addresspointers to references is maybe for some a nice way of
programming, it is in my idea a litle bit out of sense to base your
complete system on it. Like an API it is a nice way to escape as nothing
seems to be more possible, to use in general is in my idea a little bit
crazy.

What you see is that where it is needed, that need is often eliminiated in
the next version.

Is C++ not a better language for you?

Cor

"PJ6" <no***@nowhere.net> schreef in bericht
news:Oa**************@TK2MSFTNGP02.phx.gbl...
Unfortunately that has nothing to do with getting at the Set and Get
methods in a Property without first having to get the ProperyInfo with a
string representing its name...

Or am I not understanding how to apply that information to my question?

Thanks,
Paul

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:u3**************@TK2MSFTNGP05.phx.gbl...
Hi,

You should take a look at generics in vb 2005.

http://msdn2.microsoft.com/en-us/library/ms172192.aspx

Ken
-----------------------
"PJ6" <no***@nowhere.net> wrote in message
news:Om**************@TK2MSFTNGP05.phx.gbl...
I would like to refer to properties in code without having to resort to
using a string for the name. AddessOf gives me this ability for methods,
but I can't find a single way to point that at the Get or Set methods of
properties directly.

Why don't I want to use a string? Well, I want to know at design time
that my property references aren't broken, much the same way I can have
this when using regular delegates.

Is this possible?

Paul



Jun 12 '06 #5
Paul,

I am not sure if this is the answer, however you can inherit almost every
class. In that way you can make it strongly typed.

Have a look at the generated strongly typed datasource in 2005 or the
generated strongly typed dataset in previous versions as it is generated.

Cor

"PJ6" <no***@nowhere.net> schreef in bericht
news:ep**************@TK2MSFTNGP04.phx.gbl...
Cor,

The reason for my desire to get pointers from property methods without
using strings is simple, and that is the holding to the principle of code
normalization. In my grid, when I want to point a column to a property in
code, I don't want to have to write out the property name with a string
such as "SomeProperty". This is wrong because there is no design-time
verification that the string is correct, and if I manage to change the
property name later, or I've misspelled it, I will have no idea that
something is broken until something fails at runtime. Put more simply, I
want design-time validation of property references. Why do you think
that's crazy?

What surprises me is that I apparently cannot generate a pointer to the
property Set and Get methods the same way I can for normal methods. For
normal methods, this isn't an issue at all, I don't need to spell the
method name out in a string to get at it for use as a delegate.

Yes. Apparently this is currently a deficiency in the Framework since no
one has chimed in to say otherwise. But I'm not going to throw my hands up
in the air and compromise my design or move to C just because I run into a
limitation like this; I will look for a way around it.

Paul

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Paul,

Are you sure that VBNet is the right program language for you.

Using addresspointers to references is maybe for some a nice way of
programming, it is in my idea a litle bit out of sense to base your
complete system on it. Like an API it is a nice way to escape as nothing
seems to be more possible, to use in general is in my idea a little bit
crazy.

What you see is that where it is needed, that need is often eliminiated
in the next version.

Is C++ not a better language for you?

Cor

"PJ6" <no***@nowhere.net> schreef in bericht
news:Oa**************@TK2MSFTNGP02.phx.gbl...
Unfortunately that has nothing to do with getting at the Set and Get
methods in a Property without first having to get the ProperyInfo with a
string representing its name...

Or am I not understanding how to apply that information to my question?

Thanks,
Paul

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:u3**************@TK2MSFTNGP05.phx.gbl...
Hi,

You should take a look at generics in vb 2005.

http://msdn2.microsoft.com/en-us/library/ms172192.aspx

Ken
-----------------------
"PJ6" <no***@nowhere.net> wrote in message
news:Om**************@TK2MSFTNGP05.phx.gbl...
>I would like to refer to properties in code without having to resort to
>using a string for the name. AddessOf gives me this ability for
>methods, but I can't find a single way to point that at the Get or Set
>methods of properties directly.
>
> Why don't I want to use a string? Well, I want to know at design time
> that my property references aren't broken, much the same way I can
> have this when using regular delegates.
>
> Is this possible?
>
> Paul
>



Jun 12 '06 #6
PJ6,
Unfortunately AddressOf only works on Subs & Functions not properties.

As Cor suggests, I too wonder what specifically you are doing that requires
the use of the underlying delegates.

If your design truely needs the delegates & using a string to retrieve them
is undesirable. Have you considered a design that uses a Get function & a
Set sub instead?

In other words, instead of:

Public Property Name As String
...

Use:

Public Function GetName() As String
...

Public Sub SetName(value As String)
...

Alternatively I would consider a design that each "property" was actually an
object instead, then instead of relying on delegates to the "properties"
method, I would use simply pass the "property" object instead. I would
consider using Generics to define the "property" object...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"PJ6" <no***@nowhere.net> wrote in message
news:Om**************@TK2MSFTNGP05.phx.gbl...
|I would like to refer to properties in code without having to resort to
| using a string for the name. AddessOf gives me this ability for methods,
but
| I can't find a single way to point that at the Get or Set methods of
| properties directly.
|
| Why don't I want to use a string? Well, I want to know at design time that
| my property references aren't broken, much the same way I can have this
when
| using regular delegates.
|
| Is this possible?
|
| Paul
|
|
Jun 14 '06 #7

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

Similar topics

15
by: kode | last post by:
im having problems trying to understand the delegates in c#, does anybody know some link where i can find a good and simple explanation? thanks
1
by: Natalia DeBow | last post by:
Hi, I am working on a Windows-based client-server application. I am involved in the development of the remote client modules. I am using asynchronous delegates to obtain information from...
12
by: Grant | last post by:
I am having great difficulty understanding this and any code samples I find online are kilometres long and complicated to understand...Please could someone give me a simple exampe of how to get a...
3
by: Pavils Jurjans | last post by:
(I am sorry to crosspost both here and in asp.net group. I think, this question quite certainly belongs better to this group, but by error I posted the question to asp.net group) Hello, I am...
2
by: =?Utf-8?B?RGVubmlz?= | last post by:
I am trying to set a property of a control from a thread started from the UI thread using Delegates. I can set the property directly in the thread if I set the form's...
6
by: =?Utf-8?B?T2xkQ2FEb2c=?= | last post by:
My question is regarding the use of delegates in C#. I see how .Net uses delegates to wire event handlers to events. It’s an object created by a single line of code by the system and that makes...
6
by: Tem | last post by:
I've read every example i could find on the subject and still couldn't figure out its proper usage. What's the point of delegates, why can't I just invoke the method directly??? Can someone...
12
by: tshad | last post by:
I have a set up javascript functions that pass function pointers and I am trying to figure out how to do the same thing in C# using delegates. // We define some simple functions here function...
69
by: raylopez99 | last post by:
They usually don't teach you in most textbooks I've seen that delegates can be used to call class methods from classes that are 'unaware' of the delegate, so long as the class has the same...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
1
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...
0
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...

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.