using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; using ReactiveUI; namespace Wabbajack { public static class IViewForExt { public static IReactiveBinding OneWayBindStrict( this TView view, TViewModel viewModel, Expression> vmProperty, Expression> viewProperty) where TViewModel : class where TView : class, IViewFor { return view.OneWayBind( viewModel: viewModel, vmProperty: vmProperty, viewProperty: viewProperty); } public static IReactiveBinding OneWayBindStrict( this TView view, TViewModel viewModel, Expression> vmProperty, Expression> viewProperty, Func selector) where TViewModel : class where TView : class, IViewFor { return view.OneWayBind( viewModel: viewModel, vmProperty: vmProperty, viewProperty: viewProperty, selector: selector); } public static IReactiveBinding BindStrict( this TView view, TViewModel viewModel, Expression> vmProperty, Expression> viewProperty) where TViewModel : class where TView : class, IViewFor { return view.Bind( viewModel: viewModel, vmProperty: vmProperty, viewProperty: viewProperty); } public static IReactiveBinding BindStrict( this TView view, TViewModel viewModel, Expression> vmProperty, Expression> viewProperty, IObservable signalViewUpdate, Func vmToViewConverter, Func viewToVmConverter) where TViewModel : class where TView : class, IViewFor { return view.Bind( viewModel: viewModel, vmProperty: vmProperty, viewProperty: viewProperty, signalViewUpdate: signalViewUpdate, vmToViewConverter: vmToViewConverter, viewToVmConverter: viewToVmConverter); } public static IReactiveBinding BindStrict( this TView view, TViewModel viewModel, Expression> vmProperty, Expression> viewProperty, Func vmToViewConverter, Func viewToVmConverter) where TViewModel : class where TView : class, IViewFor { return view.Bind( viewModel: viewModel, vmProperty: vmProperty, viewProperty: viewProperty, vmToViewConverter: vmToViewConverter, viewToVmConverter: viewToVmConverter); } public static IDisposable BindToStrict( this IObservable @this, TTarget target, Expression> property) where TTarget : class { return @this .ObserveOnGuiThread() .BindTo(target, property); } /// /// Just a function to signify a field is being used, so it triggers compile errors if it changes /// public static void MarkAsNeeded( this TView view, TViewModel viewModel, Expression> vmProperty) where TViewModel : class where TView : class, IViewFor { } } }