Exemplo n.º 1
0
 public CsvFileReader(Stream source, CsvFileConfiguration config, int bufferSize = 1000000)
 {
     this.reader     = new StreamReader(source);
     this.qualifier  = !string.IsNullOrWhiteSpace(config?.TextQualifier) ? config.TextQualifier[0] : '"';
     this.delimiter  = !string.IsNullOrWhiteSpace(config?.Delimiter) ? config.Delimiter[0] : ',';
     this.bufferSize = bufferSize;
     this.buffer     = new ConcurrentQueue <DataRecord>();
     this.config     = config;
 }
Exemplo n.º 2
0
        static void CsvExample()
        {
            IListConfiguration <Person> peopleConfig =
                new CsvFileConfiguration <Person>("Example.csv");
            List <Person> people = peopleConfig.Load();

            foreach (var person in people)
            {
                Console.WriteLine(person);
            }
        }
Exemplo n.º 3
0
        public CsvFileWriter(Stream target, CsvFileConfiguration config)
        {
            this.config      = config;
            this.writer      = new StreamWriter(target);
            this.dictBuffer  = new ConcurrentBag <Dictionary <string, IValue> >();
            this.buffer      = new ConcurrentBag <string>();
            this.tokenSource = new CancellationTokenSource();
            var tasks = new List <Task>();

            for (var i = 0; i < Environment.ProcessorCount; i++)
            {
                tasks.Add(Task.Run(() => this.PrepareTask(this.tokenSource.Token)));
            }
            tasks.Add(Task.Run(() => this.WriteInternalTask(this.tokenSource.Token)));
            this.tasks = tasks.ToArray();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            PluginsManager pManager = PluginsManager.Instance;

            Console.WriteLine($"Current plugins count: {pManager.PluginCount}");
            Console.WriteLine($"HasType DataLoader? Answer: {pManager.HasType(PluginType.DataLoader)}");
            Console.WriteLine($"HasPlugin DataLoader? Answer: {pManager.HasType(PluginType.DataLoader)}");
            var config = new CsvFileConfiguration(@"C:\temp\config.txt");

            Console.WriteLine($"Loading plugin TestPlugin's configuration, result is: {pManager.LoadPluginConfiguration(PluginType.DataLoader, "TestPlugin",config)}");
            Console.WriteLine($"Running plugin TestPlugin, result is: {pManager.ExecutePlugin(PluginType.DataLoader, "TestPlugin")}");
            Console.WriteLine($"Printing current available plugins");
            foreach (var plugin in pManager.GetPlugins())
            {
                Console.WriteLine($"Name: {plugin.Name}, Description: {plugin.Description}, Version: {plugin.Version}, Type: {plugin.Type}");
            }
            Console.ReadKey();
        }