|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
is it possible to get delegates from properties directly?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 Hi,
You should take a look at generics in vb 2005. http://msdn2.microsoft.com/en-us/library/ms172192.aspx Ken ----------------------- Show quoteHide quote "PJ6" <no***@nowhere.net> wrote in message news:OmgeBEZjGHA.4284@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 > 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 Show quoteHide quote "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:u3Z1rvajGHA.4504@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:OmgeBEZjGHA.4284@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 >> > > 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 Show quoteHide quote "PJ6" <no***@nowhere.net> schreef in bericht news:Oa4rkFcjGHA.3816@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:u3Z1rvajGHA.4504@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:OmgeBEZjGHA.4284@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 >>> >> >> > > 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 Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:%23gWhcCejGHA.4512@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:Oa4rkFcjGHA.3816@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:u3Z1rvajGHA.4504@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:OmgeBEZjGHA.4284@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 >>>> >>> >>> >> >> > > 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 Show quoteHide quote "PJ6" <no***@nowhere.net> schreef in bericht news:ep4zg8ijGHA.1324@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]" <notmyfirstn***@planet.nl> wrote in message > news:%23gWhcCejGHA.4512@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:Oa4rkFcjGHA.3816@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:u3Z1rvajGHA.4504@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:OmgeBEZjGHA.4284@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 >>>>> >>>> >>>> >>> >>> >> >> > > 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... -- Show quoteHide quoteHope 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:OmgeBEZjGHA.4284@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 | |
Error converting FILETIME to DateTime
Read text-segment from binary file line breaks control types richtextbox selectedtext bold upper .... how to find out Tabindex is driving me nuts!!! actions done twice but only one trigger? Screen coordinates of selected datagridview cells left and top borders richtextbox property for scrolling without the scroller Delegate casting problem |
|||||||||||||||||||||||