/// <summary> /// Creates a generic binding between an HTML element and a viewmodel. This method can /// achieve all behaviours the other bind methods can, but is more complex to use. /// All parameters are optional and null can be passed. /// </summary> /// <typeparam name="T">Type of the binding, use "object" if it is unimportant.</typeparam> /// <param name="viewSetter">Can write the property to the (HTML) view.</param> /// <param name="viewNotifier">Informs about changes/clicks in the (HTML) view.</param> /// <param name="viewmodelGetter">Can read the property from the viewmodel.</param> /// <param name="viewmodelSetter">Can write the property to the viewmodel.</param> /// <param name="viewmodelNotifier">Informs about changes in the viewmodel.</param> /// <param name="bindingMode">The binding mode which defines the direction of the binding.</param> public void BindGeneric <T>( Action <T> viewSetter, HtmlViewBindingViewNotifier viewNotifier, Func <T> viewmodelGetter, Action <T> viewmodelSetter, HtmlViewBindingViewmodelNotifier viewmodelNotifier, HtmlViewBindingMode bindingMode) { var binding = new HtmlViewBinding <T>( viewSetter, viewNotifier, viewmodelGetter, viewmodelSetter, viewmodelNotifier, bindingMode); binding.ValidateBindingModeOrThrow(); _bindings.Add(binding); }
/// <summary> /// Initializes a new instance of the <see cref="HtmlViewBinding{T}"/> class. /// </summary> /// <param name="viewSetter">Can write the property to the (HTML) view.</param> /// <param name="viewNotifier">Informs about changes/clicks in the (HTML) view.</param> /// <param name="viewmodelGetter">Can read the property from the viewmodel.</param> /// <param name="viewmodelSetter">Can write the property to the viewmodel.</param> /// <param name="viewmodelNotifier">Informs about changes in the viewmodel.</param> /// <param name="bindingMode">The binding mode which defines the direction of the binding.</param> public HtmlViewBinding( Action <T> viewSetter, HtmlViewBindingViewNotifier viewNotifier, Func <T> viewmodelGetter, Action <T> viewmodelSetter, HtmlViewBindingViewmodelNotifier viewmodelNotifier, HtmlViewBindingMode bindingMode) { _viewSetter = viewSetter; ViewNotifier = viewNotifier; _viewmodelGetter = viewmodelGetter; _viewmodelSetter = viewmodelSetter; BindingMode = bindingMode; ViewmodelNotifier = viewmodelNotifier; if (ViewNotifier != null) { ViewNotifier.Notified += ViewNotifiedEventHandler; } if (ViewmodelNotifier != null) { ViewmodelNotifier.Notified += ViewmodelNotifiedEventHandler; } }
/// <summary> /// Initializes a new instance of the <see cref="CheckboxHtmlViewBinding"/> class. /// </summary> /// <param name="viewSetter">Can write the property to the (HTML) view.</param> /// <param name="viewNotifier">Informs about changes/clicks in the (HTML) view.</param> /// <param name="viewmodelGetter">Can read the property from the viewmodel.</param> /// <param name="viewmodelSetter">Can write the property to the viewmodel.</param> /// <param name="viewmodelNotifier">Informs about changes in the viewmodel.</param> /// <param name="bindingMode">The binding mode which defines the direction of the binding.</param> public CheckboxHtmlViewBinding(Action <bool> viewSetter, HtmlViewBindingViewNotifier viewNotifier, Func <bool> viewmodelGetter, Action <bool> viewmodelSetter, HtmlViewBindingViewmodelNotifier viewmodelNotifier, HtmlViewBindingMode bindingMode) : base(viewSetter, viewNotifier, viewmodelGetter, viewmodelSetter, viewmodelNotifier, bindingMode) { }