-
-
Save Pilchie/3489783 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var view = new MyView(); | |
view.Bind/*<MyViewModel, MyView, int>*/(view.ViewModel, vm => vm.Prop1, v => v.Prop2); | |
} | |
} | |
class MyViewModel | |
{ | |
public int Prop1 { get; set; } | |
} | |
class MyView : IViewFor<MyViewModel> | |
{ | |
public int Prop2 { get; set; } | |
public MyViewModel ViewModel | |
{ | |
get { return null; } | |
} | |
} | |
static class C | |
{ | |
public static IDisposable Bind<TViewModel, TView, TProp>( | |
this TView view, | |
TViewModel vm, | |
Expression<Func<TViewModel, TProp>> vmProperty, | |
Expression<Func<TView, TProp>> viewProperty) | |
where TViewModel : class | |
where TView : IViewFor<TViewModel> | |
{ | |
return null; | |
} | |
} | |
interface IViewFor<TViewModel> | |
{ | |
TViewModel ViewModel { get; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var view = new MyView();
view.Bind/<MyViewModel, MyView, int>/(view.ViewModel, vm => vm.Prop1, v => v.Prop2);
}
}
}