|
Prev: Problems with VB6 After Windows XP Service Pack 3?
Next: stellenmarkt deutschland firma deutschland Einkaeufer Einkaeuferin jobangebote weltweit
From: Etienne-Louis Nicolet on 25 Jun 2008 04:47 I am working on an error handler class. Within a property set method of a given class property I'd like to pass the PropertyInfo to a function. Imagine something like: Public Class MyClass .... Public Property MyProperty() as String Get Return _myProperty End Get Set (ByVal pMyProperty as String) ' Validate property. If there's an error, add an item to the error handler MyErrorHandler.AddError([MyProperty], errorCode) ' <--- How to get the reference to 'MyProperty'? End Set End Property .... End Class Public Class MyErrorHandler .... Public Sub AddError(ByVal pProperty As System.Reflection.PropertyInfo, pErrorCode As Integer) .... End Sub .... End Class Many thanks for any suggestions, Etienne
From: Jim Mack on 25 Jun 2008 05:17 Etienne-Louis Nicolet wrote: > I am working on an error handler class. Within a property set > method of a given class property I'd like to pass the PropertyInfo > to a function. Imagine something like: You'll have better luck posting in a group with "dotnet" in its name. The .vb. groups are for VB6 and earlier. -- Jim
From: Bill McCarthy on 25 Jun 2008 05:30 Hi Etienne, Best to ask dotnet questions for vb in the: microsoft.public.dotnet.languages.vb group. As to your question, I think you'll need to do something like: MyErrorHandler.AddError(GetType(TheClass)GetProperty("MyProperty"), errorCode) "Etienne-Louis Nicolet" <nie.msft(a)enicolet.ch> wrote in message news:%23GdVWCq1IHA.5560(a)TK2MSFTNGP02.phx.gbl... >I am working on an error handler class. Within a property set method of a >given class property I'd like to pass the PropertyInfo to a function. >Imagine something like: > > Public Class MyClass > .... > Public Property MyProperty() as String > Get > Return _myProperty > End Get > Set (ByVal pMyProperty as String) > ' Validate property. If there's an error, add an item to the > error handler > MyErrorHandler.AddError([MyProperty], errorCode) ' <--- How to > get the reference to 'MyProperty'? > End Set > End Property > .... > End Class > > > Public Class MyErrorHandler > .... > Public Sub AddError(ByVal pProperty As System.Reflection.PropertyInfo, > pErrorCode As Integer) > .... > End Sub > .... > End Class > > > Many thanks for any suggestions, > Etienne >
From: Etienne-Louis Nicolet on 25 Jun 2008 06:44 Hi Bill, Thanks for your quick reply. Sorry for having addressed the wrong group, I'll put my question there. As to my question, the idea was to have a syntax that does not hard-code the property name like ...GetProperty("MyProperty"), but rather uses Intellisense. We'll see what ideas I'll get on the appropriate discussion group. Kind regards, Etienne "Bill McCarthy" <Bill(a)N0SPAM.com> wrote in message news:A9BD5B60-169C-4D3A-ACC5-73C266DE756B(a)microsoft.com... > Hi Etienne, > > Best to ask dotnet questions for vb in the: > microsoft.public.dotnet.languages.vb > group. > > As to your question, I think you'll need to do something like: > > MyErrorHandler.AddError(GetType(TheClass)GetProperty("MyProperty"), > errorCode) > > > > > > "Etienne-Louis Nicolet" <nie.msft(a)enicolet.ch> wrote in message > news:%23GdVWCq1IHA.5560(a)TK2MSFTNGP02.phx.gbl... >>I am working on an error handler class. Within a property set method of a >>given class property I'd like to pass the PropertyInfo to a function. >>Imagine something like: >> >> Public Class MyClass >> .... >> Public Property MyProperty() as String >> Get >> Return _myProperty >> End Get >> Set (ByVal pMyProperty as String) >> ' Validate property. If there's an error, add an item to the >> error handler >> MyErrorHandler.AddError([MyProperty], errorCode) ' <--- How to >> get the reference to 'MyProperty'? >> End Set >> End Property >> .... >> End Class >> >> >> Public Class MyErrorHandler >> .... >> Public Sub AddError(ByVal pProperty As System.Reflection.PropertyInfo, >> pErrorCode As Integer) >> .... >> End Sub >> .... >> End Class >> >> >> Many thanks for any suggestions, >> Etienne >> >
From: Bill McCarthy on 25 Jun 2008 06:54
Hi Etienne, "Etienne-Louis Nicolet" <nie.msft(a)enicolet.ch> wrote in message news:OObByDr1IHA.4004(a)TK2MSFTNGP03.phx.gbl... > Hi Bill, > > Thanks for your quick reply. Sorry for having addressed the wrong group, > I'll put my question there. As to my question, the idea was to have a > syntax that does not hard-code the property name like > ...GetProperty("MyProperty"), but rather uses Intellisense. We'll see what > ideas I'll get on the appropriate discussion group. > Unfortunately you'll find the answer is there is no way. It is one of the things I have asked the Vb team to include in the language syntax. A slightly different approach you can try is the use of a dependcy property kind of model. I think Rocky Lkhota switched his object model over to that in CSLA. |