VersaTul.Collection.Streamers
                              
                            
                                1.0.31
                            
                        
                            
                                
                                
                                    Prefix Reserved
                                
                            
                    dotnet add package VersaTul.Collection.Streamers --version 1.0.31
NuGet\Install-Package VersaTul.Collection.Streamers -Version 1.0.31
<PackageReference Include="VersaTul.Collection.Streamers" Version="1.0.31" />
<PackageVersion Include="VersaTul.Collection.Streamers" Version="1.0.31" />
<PackageReference Include="VersaTul.Collection.Streamers" />
paket add VersaTul.Collection.Streamers --version 1.0.31
#r "nuget: VersaTul.Collection.Streamers, 1.0.31"
#:package VersaTul.Collection.Streamers@1.0.31
#addin nuget:?package=VersaTul.Collection.Streamers&version=1.0.31
#tool nuget:?package=VersaTul.Collection.Streamers&version=1.0.31
VersaTul Collection Streamers
VersaTul Collection Streamers is a library that provides functionality to quickly convert a collection of objects in memory into a data-reader that can be used for bulk inserting data into a SQL Database, or be used to generate flat files. It also works with display attributes to manipulate the properties on the objects in the collection.
Features
- Convert from a data-reader to other file formats such as CSV, TAB or JSON
 - Use display attributes to format or rename the properties
 - Send streamers via email attachments
 - Save streamers to physical files on disk
 - Compress streamers for transport over the network
 - Convert any collection to an IDataReader
 
Installation
To use VersaTul Collection Streamers, first install it using nuget:
PM> NuGet\Install-Package VersaTul.Collection.Streamers -Version latest
Usage
The library provides several interfaces and classes to create and manipulate streamers. Here are some of the main ones:
IStreamer: A base interface that represents the data contained in the stream and the functionality that can be applied to the data.IStreamCreator: A base interface that represents the functionality for creating streamers.ICsvStreamer: A specific stream type interface that represents the functionality for creating csv streamers.ITabStreamer: A specific stream type interface that represents the functionality for creating tab streamers.IJsonStreamer: A specific stream type interface that represents the functionality for creating json streamers.BaseStreamer: A concrete implementation of theIStreamerandIStreamCreatorinterfaces. Providing common functionality for all streamers.CsvStreamer: A concrete implementation of theICsvStreamerinterface.JsonStreamer: A concrete implementation of theIJsonStreamerinterface.TabStreamer: A concrete implementation of theITabStreamerinterface.IMailTransporter: Represents a set of functionality to send streamers via email attachments.IStreamFileConverter: Represent a set of conversion techniques that can be applied to a streamer.ICompressTransport: Represents a set of functionality to reduce streamers for transport over the network.CollectionReaderExtensions: Contains theToReadermethod that can be used to convert any collection to anIDataReader.
Here is a simple example of using the CsvStreamer to create a csv file from a collection of Person objects:
using VersaTul.Collection.Streamers;
using VersaTul.Collection.Streamers.Compressions;
using VersaTul.Collection.Streamers.Converters;
using VersaTul.Compression;
using VersaTul.Handler.File;
using VersaTul.Object.Converters;
using VersaTul.Utilities;
namespace CollectionStreamers
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create N number of data model
            var people = GetPeople(1000);
            // Create Needed Instances
            var directoryWrapper = new DirectoryWrapper();
            var utility = new CommonUtility();
            var flattener = new Flattener();
            var zipper = new Zipper(new Archiver());
            var compressor = new Compressor(zipper);
            var fileUtil = new FileUtility(directoryWrapper, directoryWrapper);
            var fileConvert = new FileConverter(fileUtil, compressor);
            // Creating the CsvStreamer Instance
            var csvStreamer = new CsvStreamer(utility, fileUtil, flattener);
            // Create CSV from given people collection
            var csv = csvStreamer.Create(people, "people");
            // Save csv to Path
            fileConvert.Save(csv, "C:\\your\\file\\path\\here\\", false);
        }
        // Helper method for generating list of data model.
        private static IEnumerable<Person> GetPeople(int amount)
        {
            var people = new List<Person>(amount);
            var names = new[] { "John Doe", "Jane Smith", "Susan Williams", "Mike Burger", "Joe Williams", "Timmy Smith", "Lisa Ray", "Stanley Smith", "Sam Jones", };
            for (int i = 0; i < amount; i++)
            {
                people.Add(new Person
                {
                    Age = i + 10,
                    Name = CommonUtil.RandomSampler(names),
                    AccountBalance = (100.99m * i),
                    BestFriend = CommonUtil.RandomSampler(people)
                });
            }
            return people;
        }
    }
    // Data Model
    public class Person
    {
        public int Age { get; set; }
        public string? Name { get; set; }
        public decimal AccountBalance { get; set; }
        public IEnumerable<Person>? Friends { get; set; }
        public Person? BestFriend { get; set; }
    }
    // Helper class
    public static class CommonUtil
    {
        public static T? RandomSampler<T>(IList<T> source)
        {
            var max = source.Count;
            if (max == 0) return default;
            var rand = new Random();
            var position = rand.Next(max);
            return source[position];
        }
    }
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. | 
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. | 
- 
                                                    
net8.0
- Newtonsoft.Json (>= 13.0.3)
 - VersaTul.Compression (>= 1.0.16)
 - VersaTul.Extensions (>= 1.0.15)
 - VersaTul.Handler.File (>= 1.0.19)
 - VersaTul.Mailer (>= 1.0.15)
 - VersaTul.Object.Converters (>= 1.0.14)
 - VersaTul.Utilities (>= 1.0.15)
 
 - 
                                                    
net9.0
- Newtonsoft.Json (>= 13.0.3)
 - VersaTul.Compression (>= 1.0.16)
 - VersaTul.Extensions (>= 1.0.15)
 - VersaTul.Handler.File (>= 1.0.19)
 - VersaTul.Mailer (>= 1.0.15)
 - VersaTul.Object.Converters (>= 1.0.14)
 - VersaTul.Utilities (>= 1.0.15)
 
 
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | 
|---|---|---|
| 1.0.31 | 210 | 12/10/2024 | 
| 1.0.30 | 164 | 10/12/2024 | 
| 1.0.29 | 189 | 5/30/2024 | 
| 1.0.28 | 188 | 4/5/2024 | 
| 1.0.27 | 183 | 4/4/2024 | 
| 1.0.26 | 178 | 4/4/2024 | 
| 1.0.25 | 204 | 3/1/2024 | 
| 1.0.24 | 179 | 2/2/2024 | 
| 1.0.23 | 195 | 1/28/2024 | 
| 1.0.22 | 173 | 1/25/2024 | 
| 1.0.21 | 172 | 1/23/2024 | 
| 1.0.20 | 169 | 1/23/2024 | 
| 1.0.19 | 172 | 1/15/2024 | 
| 1.0.18 | 178 | 1/11/2024 | 
| 1.0.17 | 167 | 1/11/2024 | 
| 1.0.16 | 172 | 1/11/2024 | 
| 1.0.15 | 197 | 12/16/2023 | 
| 1.0.14 | 225 | 11/2/2023 | 
| 1.0.13 | 249 | 7/24/2023 | 
| 1.0.12 | 236 | 7/22/2023 |