public void Convert_ShouldReturnCorrectValue(string value, TestEnum expected) { //act var actual = _sut.Convert(value, CultureInfo.InvariantCulture); //assert Assert.Equal(expected, actual); }
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 + ".")); }
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); }
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)); }
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); }
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()); }
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 }