public void DefaultTranslator_Activate_ReturnsValue() { var activator = new TranslateActivator(); var value = activator.Activate(typeof(DefaultTranslator <string>), typeof(string), @"c:\temp"); value.ShouldBe(@"c:\temp"); }
public override void Set(OptionInfo info, string arg) { var argIndex = ArgList.IndexOf(arg); var argValue = ArgList[argIndex + 1]; var value = TranslateActivator.Activate(info.TranslatorType, info.TargetType, argValue); var property = typeof(TOptions).GetProperty(info.Name); property?.SetValue(Options, value); }
public void CustomTranslator_Activate_ReturnsValue() { var activator = new TranslateActivator(); var value = (string[])activator.Activate( typeof(TestLoggerListTranslator), typeof(string[]), "Console,File"); value[0].ShouldBe("Console"); value[1].ShouldBe("File"); }
public override void Set(OptionInfo info, string arg) { object value = null; if (arg != null) { var argIndex = ArgList.IndexOf(arg); var argValue = ArgList[argIndex + 1]; value = TranslateActivator.Activate(info.TranslatorType, info.TargetType, argValue); } value = value ?? info.DefaultValue; if (value == null) { return; } var property = typeof(TOptions).GetProperty(info.Name); property?.SetValue(Options, value); }