public DelimitedErrorHandlingTests()
        {
            layout = A.Fake <IDelimitedLayoutDescriptor>();
            A.CallTo(() => layout.TargetType).Returns(typeof(Record));
            A.CallTo(() => layout.InstanceFactory).Returns(() => new Record());

            lineParserFactory = A.Fake <IDelimitedLineParserFactory>();
            A.CallTo(() => lineParserFactory.GetParser(A <IDelimitedLayoutDescriptor> .Ignored))
            .Returns(new FakeLineParser());
        }
예제 #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,
     Func <string, Exception, bool> handleEntryReadError = null)
     : base(handleEntryReadError)
 {
     _builderFactory   = builderFactory;
     _parserFactory    = parserFactory;
     _layoutDescriptor = layoutDescriptor;
 }
예제 #3
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);
 }
        /// <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));
        }
예제 #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;
 }