Exemplo n.º 1
0
        protected override void CoreTerminate()
        {
            if ((object)this.DelimitedTextWriter != null)
            {
                this.DelimitedTextWriter.Flush();
                this.DelimitedTextWriter.Dispose();
            }

            this.DelimitedTextWriter = null;
        }
Exemplo n.º 2
0
        protected override void CoreInitialize()
        {
            AdapterConfiguration <DelimitedTextAdapterConfiguration> sourceAdapterConfiguration;
            DelimitedTextSpec effectiveDelimitedTextSpec;

            if (DataTypeFascade.Instance.IsNullOrWhiteSpace(this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextFilePath))
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "DestinationAdapterConfiguration.DelimitedTextAdapterConfiguration.DelimitedTextFilePath"));
            }

            sourceAdapterConfiguration = new AdapterConfiguration <DelimitedTextAdapterConfiguration>(((ObfuscationConfiguration)this.AdapterConfiguration.Parent).SourceAdapterConfiguration);

            if ((object)this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec == null &&
                ((object)sourceAdapterConfiguration == null ||
                 (object)sourceAdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec == null))
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "[Source/Destination]...DelimitedTextSpec"));
            }

            if ((object)this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec != null)
            {
                effectiveDelimitedTextSpec = this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec;

                if (effectiveDelimitedTextSpec.HeaderSpecs.Count <= 0 &&
                    (object)sourceAdapterConfiguration != null &&
                    (object)sourceAdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec.HeaderSpecs != null)
                {
                    effectiveDelimitedTextSpec.HeaderSpecs.AddRange(sourceAdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec.HeaderSpecs);
                }
            }
            else
            {
                effectiveDelimitedTextSpec = this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec;
            }

            if ((object)effectiveDelimitedTextSpec == null ||
                effectiveDelimitedTextSpec.HeaderSpecs.Count <= 0)
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "[Source/Destination]...DelimitedTextSpec.HeaderSpecs"));
            }

            this.DelimitedTextWriter = new DelimitedTextWriter(new StreamWriter(File.Open(this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextFilePath, FileMode.Create, FileAccess.Write, FileShare.None)), effectiveDelimitedTextSpec);
        }