using System; namespace OpenSEMI.ClientBase.Command { public class CommandParameter<TCustomParameter> { public TCustomParameter CustomParameter { get; private set; } protected CommandParameter(TCustomParameter customParameter) { CustomParameter = customParameter; } public static CommandParameter<TCustomParameter> Cast(object parameter) { CommandParameter<object> commandParameter = parameter as CommandParameter<object>; if (commandParameter == null) { throw new InvalidCastException($"Failed to case {parameter.GetType()} to {typeof(CommandParameter<object>)}"); } return new CommandParameter<TCustomParameter>((TCustomParameter)commandParameter.CustomParameter); } } }