public IParameterValueViewModel Create( DataCollectionProtocolParameterType selectedParameterType, string dataType = null, string value = null) { switch (selectedParameterType) { case DataCollectionProtocolParameterType.Text: return(new TextParameterViewModel(value)); case DataCollectionProtocolParameterType.Number: return(new NumberParameterViewModel(value)); case DataCollectionProtocolParameterType.Date: return(new DateParameterViewModel(value)); case DataCollectionProtocolParameterType.UnitValue: return(new UnitValueParameterViewModel(value)); case DataCollectionProtocolParameterType.DataType: var selectedDataType = dataType; return(selectedDataType != null ? new DataTypeParameterViewModel(selectedDataType, dataApiClient, value) : null); default: throw new ArgumentOutOfRangeException(nameof(selectedParameterType), selectedParameterType, null); } }
public DataCollectionProtocolParameter( string name, string defaultValue, bool isMandatory, DataCollectionProtocolParameterType type, string dataType = null) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Value cannot be null or empty.", nameof(name)); } Name = name; DefaultValue = defaultValue; IsMandatory = isMandatory; Type = type; if (type == DataCollectionProtocolParameterType.DataType) { DataType = dataType ?? throw new ArgumentNullException(nameof(dataType)); } }