protected virtual IEnumerable <string[]> GetIterableData(TextFileSettings settings) { // //read the file, one line at a time var separator = new string[] { settings.ColumnSeparator }; using (var reader = new StreamReader(File.OpenRead(settings.Path))) { var firstLine = true; while (!reader.EndOfStream) { var line = reader.ReadLine(); if (firstLine && settings.ColumnHeadersInFirstLine) { firstLine = false; continue; } if (string.IsNullOrWhiteSpace(line)) { continue; } // //split the line into an array, using the separator var values = line.Split(separator, StringSplitOptions.None); yield return(values); } } }
protected override void AddPlugins(ItemModel source, Endpoint endpoint) { // //create the plugin var settings = new TextFileSettings { // //populate the plugin using values from the item ColumnHeadersInFirstLine = this.GetBoolValue(source, TemplateFieldColumnHeadersInFirstLine), ColumnSeparator = this.GetStringValue(source, TemplateFieldColumnSeparator), Path = this.GetStringValue(source, TemplateFieldPath) }; // //add the plugin to the endpoint endpoint.AddPlugin(settings); }