/// <summary> /// Initializes a new instance of the <see cref="FixedLengthFileEngine"/> class. /// </summary> /// <param name="layoutDescriptor">The layout descriptor.</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> internal FixedLengthFileEngine( IFixedLengthLayoutDescriptor layoutDescriptor, IFixedLengthLineBuilderFactory lineBuilderFactory, IFixedLengthLineParserFactory lineParserFactory, FileReadErrorHandler handleEntryReadError = null) : base(handleEntryReadError) { _lineBuilderFactory = lineBuilderFactory; _lineParserFactory = lineParserFactory; _layoutDescriptor = new FixedLengthImmutableLayoutDescriptor(layoutDescriptor); }
/// <summary> /// Initializes a new instance of the <see cref="FixedLengthFileEngine"/> class. /// </summary> /// <param name="layoutDescriptor">The layout descriptor.</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> internal FixedLengthFileEngine( ILayoutDescriptor <IFixedFieldSettingsContainer> layoutDescriptor, IFixedLengthLineBuilderFactory lineBuilderFactory, IFixedLengthLineParserFactory lineParserFactory, Func <string, Exception, bool> handleEntryReadError = null) : base(handleEntryReadError) { this.lineBuilderFactory = lineBuilderFactory; this.lineParserFactory = lineParserFactory; this.layoutDescriptor = layoutDescriptor; }
public FixedLengthErrorHandlingTests() { layout = A.Fake <IFixedLengthLayoutDescriptor>(); A.CallTo(() => layout.TargetType).Returns(typeof(Record)); A.CallTo(() => layout.InstanceFactory).Returns(() => new Record()); lineParserFactory = A.Fake <IFixedLengthLineParserFactory>(); A.CallTo(() => lineParserFactory.GetParser(A <IFixedLengthLayoutDescriptor> .Ignored)) .Returns(new FakeLineParser()); }
/// <summary> /// Initializes a new instance of the <see cref="FixedLengthFileMultiEngine"/> 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 FixedLengthFileMultiEngine( IEnumerable <IFixedLengthLayoutDescriptor> layoutDescriptors, Func <string, int, Type> typeSelector, IFixedLengthLineBuilderFactory lineBuilderFactory, IFixedLengthLineParserFactory lineParserFactory, IMasterDetailStrategy masterDetailStrategy, FileReadErrorHandler?handleEntryReadError = null) : base(layoutDescriptors, handleEntryReadError) { _layoutDescriptors = layoutDescriptors.Select(ld => new FixedLengthImmutableLayoutDescriptor(ld)) .Cast <IFixedLengthLayoutDescriptor>() .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)); }
/// <summary> /// Initializes a new instance of the <see cref="FixedLengthFileMultiEngine"/> 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 FixedLengthFileMultiEngine( IEnumerable<ILayoutDescriptor<IFixedFieldSettingsContainer>> layoutDescriptors, Func<string, int, Type> typeSelectorFunc, IFixedLengthLineBuilderFactory lineBuilderFactory, IFixedLengthLineParserFactory 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; }