Exemplo n.º 1
0
        public void SplitOnlyOutsideBracketsTest()
        {
            string        line  = "12-34(56-8-9)3456-4(555-7)";
            List <string> lines = UtilStrings.SplitOnlyOutsideBrackets(line, "-", "#");

            Assert.AreEqual(3, lines.Count, string.Empty);
        }
        private List <Formula> GetSubFormulas(string line)
        {
            if (String.IsNullOrEmpty(line))
            {
                return(new List <Formula>());
            }
            else
            {
                List <Formula> formulas = new List <Formula>();
                List <string>  lines    = UtilStrings.SplitOnlyOutsideBrackets(line, Constants.GroupSeperator, "#");

                for (int counter = 0; counter < lines.Count; counter++)
                {
                    line = lines[counter];
                    if (line.EndsWith(Constants.SubChainEnd, StringComparison.OrdinalIgnoreCase))
                    {
                        string locationsString = lines[counter - 1];
                        Group  group           = new Group(locationsString, line);
                        formulas.AddRange(group.Formulas);
                    }
                    else if ((line.StartsWith(Constants.StartBracket, StringComparison.OrdinalIgnoreCase)) && (line.EndsWith(Constants.EndBracket, StringComparison.OrdinalIgnoreCase)))
                    {
                        string locationsString = lines[counter - 1];
                        Group  group           = new Group(locationsString, line);
                        formulas.AddRange(group.Formulas);
                    }
                }
                return(formulas);
            }
        }