public void GetValueOfFlag() { List <FlagValue> flags = new List <FlagValue> { new FlagValue("test a", 10), new FlagValue("test b", 20), new FlagValue("test c", 30), }; Assert.AreEqual(20, StoryModel.GetValueOfFlag("Test B", flags)); }
public string ConvertNumbersToWords(string text, List <FlagValue> flags) { var pattern = @"\[\s*(number|value)\s*\:\s*(.*?)\s*\]"; var matchSet = Regex.Matches(text, pattern); foreach (Match match in matchSet) { int number = StoryModel.GetValueOfFlag(match.Groups[2].Value, flags); string numberWords = number.ToString(); if (match.Groups[1].Value == "value") { numberWords = NumToWords.Convert(number); } text = Regex.Replace(text, pattern, numberWords); } return(text); }