Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 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));
     }
 }