public void Convert_ShouldReturnCorrectValue(string value, TestEnum expected)
        {
            //act
            var actual = _sut.Convert(value, CultureInfo.InvariantCulture);

            //assert
            Assert.Equal(expected, actual);
        }
Example #2
0
        public void Function(StringValue type)
        {
            var stec  = new StringToEnumConverter(typeof(DisplayStyle));
            var value = stec.Convert(type);

            Context.DefaultDisplayStyle = (DisplayStyle)value;
            Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Information, "Display format changed to " + value + "."));
        }
Example #3
0
        public void Function(StringValue window)
        {
            var converter     = new StringToEnumConverter(typeof(Dialog));
            var dialog        = (Dialog)converter.Convert(window);
            var dialogManager = _application.Get <IDialogManager>();

            dialogManager.Open(dialog);
        }
Example #4
0
        public UserTaskProfile()
        {
            CreateMap <CreateUserTaskRequest, UserTask>()
            .ForMember(t => t.PriorityId, opt => opt.MapFrom(ut =>
                                                             StringToEnumConverter <UserTaskPriorityTags> .Convert(ut.PriorityTag)))
            .ForMember(t => t.Project, opt => opt.Ignore());

            CreateMap <UserTask, UserTaskResponse>()
            .ForMember(t => t.Priority, opt => opt.MapFrom(ut => ut.Priority.Id));
        }
Example #5
0
        public ScalarValue Function(StringValue p, ScalarValue value)
        {
            var conv         = new StringToEnumConverter(typeof(VideoProperty));
            var property     = (VideoProperty)conv.Convert(p);
            var deviceReader = default(VideoDeviceReader);

            if (NamedProperties.TryGetValue(property, out deviceReader))
            {
                deviceReader.SetValue(_sensor, value);
            }

            return(value);
        }
Example #6
0
        public ScalarValue Function(StringValue p)
        {
            var conv     = new StringToEnumConverter(typeof(AudioProperty));
            var property = (AudioProperty)conv.Convert(p);
            var callback = default(Func <Microphone, ScalarValue>);

            if (NamedProperties.TryGetValue(property, out callback))
            {
                return(callback(_sensor));
            }

            return(new ScalarValue());
        }
Example #7
0
    private object ConvertTo(string argument, Type parameterType)
    {
        foreach (var converter in conversions)
        {
            if (converter.SourceType == argument.GetType())
            {
                if (converter.TargetType == parameterType)
                {
                    Debug.Log("Converting with " + converter.Converter.ToString());
                    return(converter.Converter.GeneralConversion(argument));
                }
            }
        }
        // Didn't find any available converters
        if (parameterType.IsSubclassOf(typeof(Enum)))
        {
            Debug.Log("Converting with automatic Enum Converter");
            enumConverter.ConversionEnumType = parameterType;
            return(enumConverter.Convert(argument));
        }

        return(null); //TODO: Fix this
    }