예제 #1
0
        public static QifConversionResult ConvertTextToQif(FormatType.FormatTypeEnum formatType, List<string> inputLines)
        {
            var conversionResult = new QifConversionResult {Header = GetQifHeader(formatType)};

            ConvertLinesToQif(formatType, inputLines, conversionResult);

            conversionResult.Success = conversionResult.FailedLines.Count < 1;
            return conversionResult;
        }
예제 #2
0
        public QifConversionResult ConvertText(List<string> inputLines)
        {
            var result = new QifConversionResult();

            var parser = ParserFactory.GetParser(_formatType);

            var parseResult = parser.ParseLines(inputLines);

            var outputCreator = new QifOutputCreator();
            result.Output = outputCreator.CreateOutput(parseResult, _formatType);
            result.Success = true;

            return result;
        }
예제 #3
0
        private static void ConvertLinesToQif(FormatType.FormatTypeEnum formatType, IEnumerable<string> inputLines, QifConversionResult conversionResult)
        {
            var regex = GetRegexForFormatType(formatType);

            foreach (var inputLine in inputLines)
            {
                if(string.IsNullOrWhiteSpace(inputLine))
                    continue;
                var match = regex.Match(inputLine);
                if (match.Success)
                {
                    string qifText = ConvertMatchToQif(formatType, match);
                    if (qifText == null) return;
                    conversionResult.OutputLines.Append(qifText);
                }
                else
                {
                    conversionResult.FailedLines.Add(inputLine);
                }
            }
        }