1234567891011121314151617181920212223242526272829303132333435363738 |
- using System;
- using System.Windows;
- namespace OpenSEMI.ClientBase.Command
- {
- public class PropertyCommandParameter<TCustomParameter, TValue> : CommandParameter<TCustomParameter>
- {
- public DependencyProperty Property
- {
- get;
- private set;
- }
- public TValue Value
- {
- get;
- private set;
- }
- public PropertyCommandParameter(TCustomParameter customParameter, DependencyProperty property, TValue value)
- : base(customParameter)
- {
- Property = property;
- Value = value;
- }
- public new static PropertyCommandParameter<TCustomParameter, TValue> Cast(object parameter)
- {
- PropertyCommandParameter<object, object> propertyCommandParameter = parameter as PropertyCommandParameter<object, object>;
- if (propertyCommandParameter == null)
- {
- throw new InvalidCastException($"Failed to case {parameter.GetType()} to {typeof(PropertyCommandParameter<object, object>)}");
- }
- return new PropertyCommandParameter<TCustomParameter, TValue>((TCustomParameter)propertyCommandParameter.CustomParameter, propertyCommandParameter.Property, (TValue)propertyCommandParameter.Value);
- }
- }
- }
|