/// <summary> /// Initializes a new instance of <see cref="MultiRecordFlatFileEngine{TFieldSettings, TLayoutDescriptor}"/>. /// </summary> /// <param name="layoutDescriptors">The layout descriptors.</param> /// <param name="handleEntryReadError">The handle entry read error.</param> protected MultiRecordFlatFileEngine( IEnumerable <TLayoutDescriptor> layoutDescriptors, FileReadErrorHandler handleEntryReadError) : base(handleEntryReadError) { _results = layoutDescriptors.ToDictionary(ld => ld.TargetType, _ => (IList <object>) new List <object>()); }
/// <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> /// Gets the <see cref="IFlatFileEngine" />. /// </summary> /// <param name="descriptor">The descriptor.</param> /// <param name="handleEntryReadError">The handle entry read error func.</param> /// <returns>IFlatFileEngine.</returns> public IFlatFileEngine GetEngine( IFixedLengthLayoutDescriptor descriptor, FileReadErrorHandler handleEntryReadError = null) { return(new FixedLengthFileEngine( descriptor, new FixedLengthLineBuilderFactory(), lineParserFactory, handleEntryReadError)); }
/// <summary> /// Gets the <see cref="IFlatFileEngine" />. /// </summary> /// <param name="descriptor">The descriptor.</param> /// <param name="handleEntryReadError">The handle entry read error func.</param> /// <returns>IFlatFileEngine.</returns> public IFlatFileEngine GetEngine( IDelimitedLayoutDescriptor descriptor, FileReadErrorHandler handleEntryReadError = null) { return(new DelimitedFileEngine( descriptor, new DelimitedLineBuilderFactory(), new DelimitedLineParserFactory(), handleEntryReadError)); }
/// <summary> /// Gets a file engine. /// </summary> /// <typeparam name="TEntity">The type of the t entity.</typeparam> /// <param name="engineFactory">The engine factory.</param> /// <param name="handleEntryReadError">The error handler.</param> /// <returns>A new file engine.</returns> public static IFlatFileEngine GetEngine <TEntity>( this IFlatFileEngineFactory <IFixedLengthLayoutDescriptor, IFixedFieldSettingsContainer> engineFactory, FileReadErrorHandler handleEntryReadError = null) where TEntity : class, new() { var descriptorProvider = new FixedLayoutDescriptorProvider(); var descriptor = descriptorProvider.GetDescriptor <TEntity>(); return(engineFactory.GetEngine(descriptor, handleEntryReadError)); }
/// <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> /// Gets a file engine. /// </summary> /// <param name="engineFactory">The engine factory.</param> /// <param name="recordTypes">The record types.</param> /// <param name="typeSelectorFunc">The type selector function.</param> /// <param name="handleEntryReadError">The error handler.</param> /// <returns>A new file engine.</returns> public static IFlatFileMultiEngine GetEngine( this FixedLengthFileEngineFactory engineFactory, IEnumerable <Type> recordTypes, Func <string, int, Type> typeSelectorFunc, FileReadErrorHandler handleEntryReadError = null) { var descriptorProvider = new FixedLayoutDescriptorProvider(); var descriptors = recordTypes.Select(type => descriptorProvider.GetDescriptor(type)).ToList(); return(engineFactory.GetEngine(descriptors, typeSelectorFunc, handleEntryReadError)); }
/// <summary> /// Gets a file engine. /// </summary> /// <param name="engineFactory">The engine factory.</param> /// <param name="recordTypes">The record types.</param> /// <param name="typeSelectorFunc">The type selector function.</param> /// <param name="handleEntryReadError">The error handler.</param> /// <param name="masterDetailStrategy">Determines how master-detail record relationships are handled.</param> /// <returns>IFlatFileMultiEngine.</returns> public static IFlatFileMultiEngine GetEngine( this DelimitedFileEngineFactory engineFactory, IEnumerable <Type> recordTypes, Func <string, int, Type> typeSelectorFunc, FileReadErrorHandler handleEntryReadError = null, IMasterDetailStrategy masterDetailStrategy = null) { var descriptorProvider = new DelimitedLayoutDescriptorProvider(); var descriptors = recordTypes.Select(type => descriptorProvider.GetDescriptor(type)).ToList(); return(engineFactory.GetEngine(descriptors, typeSelectorFunc, handleEntryReadError, masterDetailStrategy)); }
/// <summary> /// Gets the <see cref="IFlatFileMultiEngine"/>. /// </summary> /// <param name="layoutDescriptors">The layout descriptors.</param> /// <param name="typeSelectorFunc">The type selector function.</param> /// <param name="handleEntryReadError">The handle entry read error func.</param> /// <param name="masterDetailStrategy">Determines how master-detail record relationships are handled.</param> /// <returns>IFlatFileMultiEngine.</returns> public IFlatFileMultiEngine GetEngine( IEnumerable <IFixedLengthLayoutDescriptor> layoutDescriptors, Func <string, int, Type> typeSelectorFunc, FileReadErrorHandler handleEntryReadError = null, IMasterDetailStrategy masterDetailStrategy = null) { return(new FixedLengthFileMultiEngine( layoutDescriptors, typeSelectorFunc, new FixedLengthLineBuilderFactory(), lineParserFactory, masterDetailStrategy ?? new DefaultFixedLengthMasterDetailStrategy(), handleEntryReadError)); }
/// <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)); }
/// <summary> /// Initializes a new instance of <see cref="FlatFileEngine{TFieldSettings, TLayoutDescriptor}"/>. /// </summary> /// <param name="handleEntryReadError">The file read error handler.</param> protected FlatFileEngine(FileReadErrorHandler handleEntryReadError = null) : base(handleEntryReadError) { }
/// <summary> /// Initializes a new instance of <see cref="FileEngineCore{TFieldSettings, TLayoutDescriptor}"/>. /// </summary> /// <param name="handleEntryReadError">The file read error handler.</param> protected FileEngineCore(FileReadErrorHandler handleEntryReadError) { HandleEntryReadError = handleEntryReadError; }