Example #1
0
        public void SendData(IRelationalObject relationalObject)
        {
            if (relationalObject == null)
            {
                throw new ArgumentNullException(nameof(relationalObject));
            }

            if (!streams.ContainsKey(configuration))
            {
                var fileName = configuration.FileName;
                var factory  = new OutputStreamFactory(configuration.Format, configuration.ColumnHeaders, serialiser);
                var writer   = streamFactory.OpenWrite(fileName);
                streams.Add(configuration, new FileStream(factory.Create(writer)));
            }

            var stream = streams[configuration];

            var bindingConfig = configuration as IBindingConfiguration;

            if (bindingConfig != null)
            {
                relationalObject = relationalObject.WithForeignKey(bindingConfig);
            }

            stream.SendData(relationalObject);
        }
        public void SendData(IRelationalObject relationalObject)
        {
            if (relationalObject == null)
            {
                throw new ArgumentNullException(nameof(relationalObject));
            }

            if (!streams.ContainsKey(configuration))
            {
                var outputStreamFactory = new OutputStreamFactory(configuration.Format, configuration.ColumnHeaders, serialiser);
                streams.Add(configuration, new ProcessStream(configuration, outputStreamFactory));
            }

            var stream = streams[configuration];

            var bindingConfig = configuration as IBindingConfiguration;

            if (bindingConfig != null)
            {
                relationalObject = relationalObject.WithForeignKey(bindingConfig);
            }

            stream.SendData(relationalObject);
        }