Example #1
0
 /// <summary>
 /// Initializes a new instance of <see cref="UIActionBinding"/>.
 /// </summary>
 /// <param name="binding">
 /// A set of default suggested interfaces for a <see cref="UIAction"/>.
 /// </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="binding"/> and/or <paramref name="handler"/> are null.
 /// </exception>
 public UIActionBinding(DefaultUIActionBinding binding, UIActionHandlerFunc handler)
 {
     if (binding == null)
     {
         throw new ArgumentNullException(nameof(binding));
     }
     Action     = binding.Action;
     Interfaces = binding.DefaultInterfaces;
     Handler    = handler ?? throw new ArgumentNullException(nameof(handler));
 }
 /// <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="binding">
 /// Contains the <see cref="UIAction"/> with its suggested default <see cref="IUIActionInterface"/> set.
 /// </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="binding"/> and/or <paramref name="handler"/> are null.
 /// </exception>
 public static void BindAction <T>(this T provider, DefaultUIActionBinding binding, UIActionHandlerFunc handler)
     where T : Control, IUIActionHandlerProvider
 => BindAction(provider, new UIActionBinding(binding, handler));