/// <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 FixedLengthFileEngineWriteTests() { A.CallTo(() => _lineBuilder.BuildLine(A <TestRecord> .Ignored)) .ReturnsLazily((TestRecord r) => r.ToString()); _lineBuilderFactory = A.Fake <IFixedLengthLineBuilderFactory>(); A.CallTo(() => _lineBuilderFactory.GetBuilder(A <IFixedLengthLayoutDescriptor> .Ignored)) .Returns(_lineBuilder); _fileEngine = new FixedLengthFileEngine( A.Fake <IFixedLengthLayoutDescriptor>(), _lineBuilderFactory, new FixedLengthLineParserFactory()); }
/// <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; }