public void with_a_property_that_contains_multiple_aliases() { var optionSources = new OptionSource[] { new OptionSource("test", "alternatesecondflagalias", false, "value") }.UseAliases<TestType>(); Assert.AreEqual(1, optionSources.Count()); Assert.NotNull(optionSources.FirstOrDefault(x => x.Name.Equals("secondflag", System.StringComparison.OrdinalIgnoreCase))); Assert.AreEqual("value", optionSources.FirstOrDefault(x => x.Name.Equals("secondflag", System.StringComparison.OrdinalIgnoreCase)).Value); }
public void BattleHappen(EnemyGroup eg, OptionSource op = null) { BattleManager.information = new PassedBattleInformation { enemyGroup = eg, difficultLevel = this.difficultLevel, option = op }; SceneStatusManager.Ins.SetSceneStatus(new BattleStatus(SceneStatusManager.Ins), true, true); }
public void with_an_empty_string_as_a_value_it_should_return_true_as_the_value() { var normalizedValues = new OptionSource[] { new OptionSource("test", "flag", false, "") }.Normalize(); Assert.AreEqual(1, normalizedValues.Count()); Assert.AreEqual("flag", normalizedValues.First().Name); Assert.AreEqual(true, normalizedValues.First().IsTyped); Assert.AreEqual(true, normalizedValues.First().Value); }
public void ReceiveEvent(OptionSource option) { this.option = option; canUseFlag = true; selectedCard = null; targetCard = null; OpenCraft(CraftMode.Upgrade); }
public void with_a_positive_as_a_value_it_should_return_true_as_the_value() { var normalizedValues = new OptionSource[] { new OptionSource("test", "flag", false, "+") }.Normalize(); Assert.AreEqual(1, normalizedValues.Count()); Assert.AreEqual("flag", normalizedValues.First().Name); Assert.AreEqual(true, normalizedValues.First().IsTyped); Assert.AreEqual(true, normalizedValues.First().Value); }
private static IEnumerable <OptionSource> MyOwnCustomDefaultsAintThatNeat() { //your function can get them however you see fit yield return(OptionSource.Typed("myfunction", "shitbird", 3)); yield return(OptionSource.Typed("myfunction", "shitbird2", "hello")); yield return(OptionSource.String("myfunction", "answertoeverything", "42")); }
/// <summary> /// Entry point. /// </summary> /// <returns>Returns exit code.</returns> private static async Task <int> Main() { try { ILogger logger = new Logger(); IOptionsSource optionsSource = new OptionSource("options.json"); IRequestPerformer requestPerformer = new RequestPerformer( new RequestHandler(new HttpClient()), new ResponseHandler(), logger ); var mainMenu = new MainMenu(requestPerformer, optionsSource, logger); return(await mainMenu.StartAsync()); } catch (Exception ex) { Console.WriteLine("Critical unhandled exception"); Console.WriteLine(ex); return(-1); } }
public static OptionValue <TTarget, TProperty> Create <TTarget, TProperty>( TTarget targetObject, TProperty defaultValue, OptionSource source, string optionName) { return(new OptionValue <TTarget, TProperty>(targetObject, defaultValue, source, optionName)); }
protected OptionValue(TTarget targetObject, OptionSource source, string optionName) { TargetObject = targetObject; Source = source; _propertyInfo = typeof(TTarget).GetProperty(optionName); }