1234567891011121314151617181920212223242526272829303132333435363738 |
- using System;
- using System.Windows;
- namespace OpenSEMI.ClientBase.Command
- {
- public class EventCommandParameter<TCustomParameter, TEventArgs> : CommandParameter<TCustomParameter> where TEventArgs : RoutedEventArgs
- {
- public RoutedEvent RoutedEvent
- {
- get;
- private set;
- }
- public TEventArgs EventArgs
- {
- get;
- private set;
- }
- public EventCommandParameter(TCustomParameter customParameter, RoutedEvent routedEvent, TEventArgs eventArgs)
- : base(customParameter)
- {
- RoutedEvent = routedEvent;
- EventArgs = eventArgs;
- }
- public new static EventCommandParameter<TCustomParameter, TEventArgs> Cast(object parameter)
- {
- EventCommandParameter<object, RoutedEventArgs> eventCommandParameter = parameter as EventCommandParameter<object, RoutedEventArgs>;
- if (eventCommandParameter == null)
- {
- throw new InvalidCastException($"Failed to case {parameter.GetType()} to {typeof(EventCommandParameter<object, RoutedEventArgs>)}");
- }
- return new EventCommandParameter<TCustomParameter, TEventArgs>((TCustomParameter)eventCommandParameter.CustomParameter, eventCommandParameter.RoutedEvent, (TEventArgs)eventCommandParameter.EventArgs);
- }
- }
- }
|