|
-
Jun 3rd, 2014, 01:44 AM
#1
Thread Starter
Frenzied Member
Any way to write a method that accepts generic parameter and assign value?
Hi!
I am working on refactoring an application that is written as a Model View Presenter (winforms).
I am stuck on a scenario where the view fires events to the presenter when certain properties are changed. For example, if the user is selecting data in a combobox, an "CountryValueSelectedChanged" event is fired as an Action<int id> where id is the value selected. Same for textboxes where the keyup-event fires an OnFirstNameChanged event which is an Action<string name>.
Would it be possible to write a single OnPropertyChanged<T> method, since both the view and the presenter are aware of T (which is the domain entity) Then I just need a way to inform this generic event two things
1) The new value
2) Which property that was changed.
How do I do this in a clever way? I have on the presenter a property of type T which is called "selectedEntity; In the event handler for OnPropertyChanged<T> I want to be able to do:
"selectedEntity.X = newValue.X;"
How can I define X?
/Henrik
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|