Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelimitedFileEngine"/> class.
 /// </summary>
 /// <param name="layoutDescriptor">The layout descriptor.</param>
 /// <param name="builderFactory">The builder factory.</param>
 /// <param name="parserFactory">The parser factory.</param>
 /// <param name="handleEntryReadError">The handle entry read error.</param>
 internal DelimitedFileEngine(
     IDelimitedLayoutDescriptor layoutDescriptor,
     IDelimitedLineBuilderFactory builderFactory,
     IDelimitedLineParserFactory parserFactory,
     Func <string, Exception, bool> handleEntryReadError = null)
     : base(handleEntryReadError)
 {
     _builderFactory   = builderFactory;
     _parserFactory    = parserFactory;
     _layoutDescriptor = layoutDescriptor;
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelimitedFileEngine"/> class.
 /// </summary>
 /// <param name="layoutDescriptor">The layout descriptor.</param>
 /// <param name="builderFactory">The builder factory.</param>
 /// <param name="parserFactory">The parser factory.</param>
 /// <param name="handleEntryReadError">The handle entry read error.</param>
 internal DelimitedFileEngine(
     IDelimitedLayoutDescriptor layoutDescriptor,
     IDelimitedLineBuilderFactory builderFactory,
     IDelimitedLineParserFactory parserFactory,
     FileReadErrorHandler handleEntryReadError = null)
     : base(handleEntryReadError)
 {
     _builderFactory   = builderFactory;
     _parserFactory    = parserFactory;
     _layoutDescriptor = new DelimitedImmutableLayoutDescriptor(layoutDescriptor);
 }
        public DelimitedFileEngineWriteTests()
        {
            A.CallTo(() => _lineBuilder.BuildLine(A <TestRecord> .Ignored))
            .ReturnsLazily((TestRecord r) => r.ToString());

            _lineBuilderFactory = A.Fake <IDelimitedLineBuilderFactory>();
            A.CallTo(() => _lineBuilderFactory.GetBuilder(A <IDelimitedLayoutDescriptor> .Ignored))
            .Returns(_lineBuilder);

            _fileEngine = new DelimitedFileEngine(
                A.Fake <IDelimitedLayoutDescriptor>(),
                _lineBuilderFactory,
                new DelimitedLineParserFactory());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DelimitedFileMultiEngine"/> class.
        /// </summary>
        /// <param name="layoutDescriptors">The layout descriptors.</param>
        /// <param name="typeSelector">The type selector function.</param>
        /// <param name="lineBuilderFactory">The line builder factory.</param>
        /// <param name="lineParserFactory">The line parser factory.</param>
        /// <param name="masterDetailStrategy">Determines how master-detail record relationships are handled.</param>
        /// <param name="handleEntryReadError">The handle entry read error.</param>
        /// <exception cref="System.ArgumentNullException">typeSelectorFunc</exception>
        internal DelimitedFileMultiEngine(
            IEnumerable <IDelimitedLayoutDescriptor> layoutDescriptors,
            Func <string, int, Type> typeSelector,
            IDelimitedLineBuilderFactory lineBuilderFactory,
            IDelimitedLineParserFactory lineParserFactory,
            IMasterDetailStrategy masterDetailStrategy,
            FileReadErrorHandler handleEntryReadError = null)
            : base(layoutDescriptors, handleEntryReadError)
        {
            _layoutDescriptors = layoutDescriptors.Select(ld => new DelimitedImmutableLayoutDescriptor(ld))
                                 .Cast <IDelimitedLayoutDescriptor>()
                                 .ToDictionary(ld => ld.TargetType, ld => ld);

            _typeSelector         = typeSelector ?? throw new ArgumentNullException(nameof(typeSelector));
            _lineBuilderFactory   = lineBuilderFactory ?? throw new ArgumentNullException(nameof(lineBuilderFactory));
            _lineParserFactory    = lineParserFactory ?? throw new ArgumentNullException(nameof(lineParserFactory));
            _masterDetailStrategy = masterDetailStrategy ?? throw new ArgumentNullException(nameof(masterDetailStrategy));
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelimetedFileMultiEngine"/> class.
 /// </summary>
 /// <param name="layoutDescriptors">The layout descriptors.</param>
 /// <param name="typeSelectorFunc">The type selector function.</param>
 /// <param name="lineBuilderFactory">The line builder factory.</param>
 /// <param name="lineParserFactory">The line parser factory.</param>
 /// <param name="handleEntryReadError">The handle entry read error.</param>
 /// <exception cref="System.ArgumentNullException">typeSelectorFunc</exception>
 internal DelimitedFileMultiEngine(
     IEnumerable <IDelimitedLayoutDescriptor> layoutDescriptors,
     Func <string, Type> typeSelectorFunc,
     IDelimitedLineBuilderFactory lineBuilderFactory,
     IDelimitedLineParserFactory lineParserFactory,
     Func <string, Exception, bool> handleEntryReadError = null)
 {
     if (typeSelectorFunc == null)
     {
         throw new ArgumentNullException("typeSelectorFunc");
     }
     this.layoutDescriptors = layoutDescriptors.ToList();
     results = new Dictionary <Type, ArrayList>(this.layoutDescriptors.Count());
     foreach (var descriptor in this.layoutDescriptors)
     {
         results[descriptor.TargetType] = new ArrayList();
     }
     this.typeSelectorFunc     = typeSelectorFunc;
     this.lineBuilderFactory   = lineBuilderFactory;
     this.lineParserFactory    = lineParserFactory;
     this.handleEntryReadError = handleEntryReadError;
 }