// ReSharper disable once UnusedMember.Global // ReSharper disable once MemberCanBePrivate.Global protected IEnumerable <CommandResponse> EnabledMode() { var tokenList = (List <string>) this.Arguments; var stalkName = tokenList.PopFromFront(); if (!this.channelConfiguration[this.CommandSource].Stalks.ContainsKey(stalkName)) { throw new CommandErrorException(string.Format("Can't find the stalk '{0}'!", stalkName)); } bool enabled; var possibleBoolean = tokenList.PopFromFront(); if (!BooleanParser.TryParse(possibleBoolean, out enabled)) { throw new CommandErrorException( string.Format( "{0} is not a value of boolean I recognise. Try 'true', 'false' or ERR_FILE_NOT_FOUND.", possibleBoolean)); } yield return(new CommandResponse { Message = string.Format("Set enabled attribute on stalk {0} to {1}", stalkName, enabled) }); this.channelConfiguration[this.CommandSource].Stalks[stalkName].IsEnabled = enabled; this.channelConfiguration.Save(); }
public void BooleanParserParsingTest3() { string testValue = "error"; BooleanParser parser = new BooleanParser(); object parsedValue = parser.GetValue(testValue); }
public bool ShouldParseCorrectly(string input) { bool result; bool success = BooleanParser.TryParse(input, out result); Assert.IsTrue(success); return(result); }
public void BooleanParserParsingTest2() { string testValue = "false"; BooleanParser parser = new BooleanParser(); object parsedValue = parser.GetValue(testValue); Assert.AreEqual(false, parsedValue); }
public void BooleanParserValidationTest2() { string testValue = "false"; BooleanParser parser = new BooleanParser(); ValueValidationResult validationResult = parser.ValidateValue(testValue); Assert.AreEqual(ValueValidationResult.OK, validationResult); }
public void TestParseBoolean1() { BooleanParser parser = new BooleanParser(); bool actual = parser.ParseBoolean("true"); bool expected = true; Assert.AreEqual(expected, actual); }
public void TestParseBoolean() { var parser = new BooleanParser(); var actual = parser.Parse("true"); var expected = true; Assert.AreEqual(expected, actual); }
public void BooleanParserValidationTest3() { string testValue = "error"; BooleanParser parser = new BooleanParser(); ValueValidationResult validationResult = parser.ValidateValue(testValue); Assert.AreEqual(ValueValidationResult.TypeError, validationResult); }
public ScriptParser(IScriptParserLog logger = null, bool loadPreDefinedFunctions = true, bool loadPreDefinedOperators = true, bool loadPreDefinedVariables = true, CultureInfo cultureInfo = null) { mathParser = new MathParser(loadPreDefinedFunctions, loadPreDefinedOperators, loadPreDefinedVariables, cultureInfo); booleanParser = new BooleanParser(mathParser); this.Logger = logger; if (logger == null) { this.Logger = new NullScriptParserLog(); } }
public void TestParseBoolean2() { Dictionary<string, bool> mapping = new Dictionary<string, bool> { { "Yes", true }, { "No", false }, { "Y", true }, { "N", false } }; BooleanParser parser = new BooleanParser(mapping); bool actual = parser.ParseBoolean("No"); bool expected = false; Assert.AreEqual(expected, actual); }
private static void RunBooleanParserDemo() { // Use the default boolean parser BooleanParser parser = new BooleanParser(); bool result = parser.ParseBoolean("truE"); // converts to true bool result2 = parser.ParseBoolean("FAlse"); // converts to false // Alternatively, we can set custom strings for conversion of boolean values Dictionary<string, bool> mapping = new Dictionary<string, bool> { { "Yes", true }, { "No", false }, { "Y", true }, { "N", false } }; BooleanParser parser2 = new BooleanParser(mapping); bool result3 = parser2.ParseBoolean("true"); // converts to true bool result4 = parser2.ParseBoolean("Yes"); // converts to true bool result5 = parser2.ParseBoolean("N"); // converts to false }
private static void RunBooleanParserDemo() { // Use the default boolean parser BooleanParser parser = new BooleanParser(); var result = parser.Parse("truE"); // converts to true var result2 = parser.Parse("FAlse"); // converts to false // Alternatively, we can set custom strings for conversion of boolean values Dictionary <string, bool> mapping = new Dictionary <string, bool> { { "Yes", true }, { "No", false }, { "Y", true }, { "N", false } }; var parser2 = new BooleanMapParser(mapping); var result3 = parser2.Parse("true"); // converts to true var result4 = parser2.Parse("Yes"); // converts to true var result5 = parser2.Parse("N"); // converts to false }
public void Activate(string settingsID = null, string populationID = null, string delay = null, string triggerAlarm = null) { Activate(DataBlockIDParser <SurvivalWaveSettingsDataBlock> .Parse(settingsID), DataBlockIDParser <SurvivalWaveSettingsDataBlock> .Parse(populationID), FloatParser.Parse(delay), BooleanParser.Parse(triggerAlarm)); }
public void Initialize() { mathParser = new MathParser(); parser = new BooleanParser(mathParser); }
public void Init() { parser = new BooleanParser(); }
public void ShouldParseIncorrectly(string input) { bool result; Assert.IsFalse(BooleanParser.TryParse(input, out result)); }
public void Activate(string text = null, string displayDuration = null, string isObjectiveText = null) { Activate(text == null ? "" : text, FloatParser.Parse(displayDuration), BooleanParser.Parse(isObjectiveText)); }