示例#1
0
        private IDictionary <string, Feature> parseFile(IDictionary <string, IToggleSpecification> specificationMappings, StringBuilder exOutput)
        {
            var readFeatures = new Dictionary <string, Feature>(StringComparer.OrdinalIgnoreCase);
            var content      = _fileReader.Content();

            for (var index = 0; index < content.Length; index++)
            {
                var row                = content[index];
                var rowNumber          = index + 1;
                var indexOfCommentSign = row.IndexOf("#", StringComparison.OrdinalIgnoreCase);
                var rowWithoutComments = indexOfCommentSign > -1 ? row.Remove(indexOfCommentSign) : row;
                var splitByEqualSign   = rowWithoutComments.Split('=');
                var leftOfEqualSign    = splitByEqualSign[0].Trim();
                if (leftOfEqualSign == string.Empty)
                {
                    continue;
                }
                switch (splitByEqualSign.Length)
                {
                case 1:
                    exOutput.AppendLine(string.Format(MustContainEqualSign, rowNumber));
                    break;

                case 2:
                    var rightOfEqualSign = splitByEqualSign[1].Trim();
                    parseRow(readFeatures, specificationMappings, leftOfEqualSign, rightOfEqualSign, rowNumber, exOutput);
                    break;

                default:
                    exOutput.AppendLine(string.Format(MustOnlyContainOneEqualSign, rowNumber));
                    break;
                }
            }
            return(readFeatures);
        }