Example #1
0
 static string GetLinearValue(Input input)
 {
     return input is SingleValueInput ? ((SingleValueInput)input).Value : ((MultiValueInput)input).Values.JoinString(", ");
 }
        static IEnumerable<string> GetValues(Input input)
        {
            var s = input as SingleValueInput;
            if (s != null)
                return s.Value == string.Empty ? Enumerable.Empty<string>() : new[] { s.Value };

            var m = input as MultiValueInput;
            if (m != null)
                return m.Values;

            throw new InvalidOperationException();
        }
Example #3
0
        static bool AssignValue(Input input, ICommand command, ICommandInputDescriptor descriptor)
        {
            var s = input as SingleValueInput;
            if (s != null)
                return descriptor.TrySetValue(command, s.Value == string.Empty ? Enumerable.Empty<string>() : new[] { s.Value });

            var m = input as MultiValueInput;
            if (m != null)
                return descriptor.TrySetValue(command, m.Values);
            throw new InvalidOperationException();
        }
 static bool AssignValue(Input input, ICommand command, ICommandInputDescriptor descriptor)
 {
     return descriptor.TrySetValue(command, GetValues(input));
 }