Guest User

Untitled

a guest
Dec 11th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. var view = new MyView();
  6. view.Bind/*<MyViewModel, MyView, int>*/(view.ViewModel, vm => vm.Prop1, v => v.Prop2);
  7. }
  8. }
  9.  
  10. class MyViewModel
  11. {
  12. public int Prop1 { get; set; }
  13. }
  14.  
  15. class MyView : IViewFor<MyViewModel>
  16. {
  17. public int Prop2 { get; set; }
  18.  
  19. public MyViewModel ViewModel
  20. {
  21. get { return null; }
  22. }
  23. }
  24.  
  25. static class C
  26. {
  27. public static IDisposable Bind<TViewModel, TView, TProp>(
  28. this TView view,
  29. TViewModel vm,
  30. Expression<Func<TViewModel, TProp>> vmProperty,
  31. Expression<Func<TView, TProp>> viewProperty)
  32. where TViewModel : class
  33. where TView : IViewFor<TViewModel>
  34. {
  35. return null;
  36. }
  37. }
  38.  
  39. interface IViewFor<TViewModel>
  40. {
  41. TViewModel ViewModel { get; }
  42. }
Add Comment
Please, Sign In to add comment