Example #1
0
 /// <summary>
 /// Initializes a new instance of <see cref="DefaultUIActionBinding"/>.
 /// </summary>
 /// <param name="action">
 /// The <see cref="UIAction"/> to bind to a <see cref="UIActionHandler"/>.
 /// </param>
 /// <param name="defaultInterfaces">
 /// The suggested default <see cref="ImplementationSet{TInterface}"/> which defines how the action is exposed to the user interface.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="action"/> and/or <paramref name="defaultInterfaces"/> are null.
 /// </exception>
 public DefaultUIActionBinding(UIAction action, ImplementationSet <IUIActionInterface> defaultInterfaces)
 {
     Action            = action ?? throw new ArgumentNullException(nameof(action));
     DefaultInterfaces = defaultInterfaces ?? throw new ArgumentNullException(nameof(defaultInterfaces));
 }
 /// <summary>
 /// Binds a handler function for a <see cref="UIAction"/> to a <see cref="IUIActionHandlerProvider"/>,
 /// and specifies how this <see cref="UIAction"/> is exposed to the user interface.
 /// </summary>
 /// <typeparam name="T">
 /// The type of <paramref name="provider"/>.
 /// </typeparam>
 /// <param name="provider">
 /// The <see cref="Control"/> which allows binding of actions by implementing the <see cref="IUIActionHandlerProvider"/> interface.
 /// </param>
 /// <param name="action">
 /// The <see cref="UIAction"/> to bind.
 /// </param>
 /// <param name="interfaces">
 /// The <see cref="IUIActionInterface"/> set which defines how the action is exposed to the user interface.
 /// </param>
 /// <param name="handler">
 /// The handler function used to perform the <see cref="UIAction"/> and determine its <see cref="UIActionState"/>.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="action"/> and/or <paramref name="interfaces"/> and/or <paramref name="handler"/> are null.
 /// </exception>
 public static void BindAction <T>(this T provider, UIAction action, ImplementationSet <IUIActionInterface> interfaces, UIActionHandlerFunc handler)
     where T : Control, IUIActionHandlerProvider
 => BindAction(provider, new UIActionBinding(action, interfaces, handler));
Example #3
0
 /// <summary>
 /// Initializes a new instance of <see cref="UIActionBinding"/>.
 /// </summary>
 /// <param name="action">
 /// The <see cref="UIAction"/> to bind to a <see cref="UIActionHandler"/>.
 /// </param>
 /// <param name="interfaces">
 /// The <see cref="IUIActionInterface"/> set which defines how the action is exposed to the user interface.
 /// </param>
 /// <param name="handler">
 /// The handler function used to invoke the <see cref="UIAction"/> and determine its <see cref="UIActionState"/>.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="action"/> and/or <paramref name="interfaces"/> and/or <paramref name="handler"/> are null.
 /// </exception>
 public UIActionBinding(UIAction action, ImplementationSet <IUIActionInterface> interfaces, UIActionHandlerFunc handler)
 {
     Action     = action ?? throw new ArgumentNullException(nameof(action));
     Interfaces = interfaces ?? throw new ArgumentNullException(nameof(interfaces));
     Handler    = handler ?? throw new ArgumentNullException(nameof(handler));
 }