Пример #1
0
        public override string Execute(StringTemplateItem template)
        {
            string file = PathUtility.ParseSpecialFoldersNames(this.File, ParseSpecialFolderOption.WildCardToRealPath);

            string[]      values = new string[0];
            StringBuilder sb     = new StringBuilder();

            if (Utils.IsFileOrDirectory(file) == Utils.FileOrDirectory.File)
            {
                using (CsvStreamReader reader = new CsvStreamReader(file))
                {
                    reader.Separator = ',';

                    while (!reader.EndOfCsvStream) // Do not use EndOfStream
                    {
                        string line = reader.ReadLine();
                        values = Utils.SplitEscaped(line, reader.Separator, '"');

                        template.IsLastCommand = (reader.EndOfCsvStream && this.IsLastCommand);
                        sb.Append(template.Format(line, this.Data, values));
                    }
                    reader.Close();
                }
            }
            return(sb.ToString());
        }