예제 #1
0
 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);
 }
예제 #2
0
 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);
 }
예제 #3
0
 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);
 }
예제 #4
0
 public void ReceiveEvent(OptionSource option)
 {
     this.option  = option;
     canUseFlag   = true;
     selectedCard = null;
     targetCard   = null;
     OpenCraft(CraftMode.Upgrade);
 }
예제 #5
0
        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);
        }
예제 #6
0
        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"));
        }
예제 #7
0
 /// <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);
 }