Re: Passing property Accesor as Function`
Richard Blewett <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <003601c82ab5$3aeb5e90$b0c21bb0$@com> |
What I don't understand is why your method doesn't simple return the data instead of trying to pass a property by reference. I assume there is some underlying issue that isn't obvious from the code Regards Richard Blewett - DevelopMentor > -----Original Message----- > From: Discussion of development on the .NET platform using any managed > language [mailto:[email protected]] On Behalf Of Brady > Kelly > Sent: 19 November 2007 06:22 > To: [email protected] > Subject: [DOTNET-CLR] Passing property Accesor as Function` > > Warning: This is a purely academic and speculative post. > > > > This has suddenly become a real 'would like to have' feature in the > project > I'm currently working on. I know this isn't possible in standard C#, > but > I'm trying to find a hammer with the right weight and shape to beat > this > into some semblance of working. What I would like to achieve is > something > like this, in the commented line: > > > > public class PersonForm > > { > > System.Windows.Forms.TextBox textRate = new TextBox(); > > public void BuildPerson(Person person) > > { > > Person pers = new Person(); > > pers.HourlyRate = textRate.Text.Length == 0 ? (double?) > null : > double.Parse(textRate.Text); > > // SetPropertyFromText(pers.HourlyRate, textRate.Text) > > } > > } > > > > My SetPropertyFromText should take the pers.HourlyRate as a delegate > parameter, not as a double?, determine the correct type conversion > based on > the type of the pers.HourlyRate, and set the property to the converted > object value. > > > > I can easily use a property name as my property parameter for > SetPropertyFromText, but then I lose compile time checks. Our > generated > DAL, nettiers, provides, for each entity, an Enum with all the column > properties for each entity, and I think this is about as close as I've > seen > to what I want, but not quite there. > > > > Any ideas on the matter? > > > > > =================================== > This list is hosted by DevelopMentor. http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com