public DelimitedMasterDetailCustomTests()
        {
            _engine = _factory.GetEngine(new [] { typeof(MasterRecord), typeof(DetailRecord) },
                                         (line, number) =>
            {
                if (String.IsNullOrEmpty(line) || line.Length < 1)
                {
                    return(null);
                }

                switch (line[0])
                {
                case 'M':
                    return(typeof(MasterRecord));

                case 'D':
                    return(typeof(DetailRecord));

                default:
                    return(null);
                }
            },
                                         masterDetailStrategy: new DelegatingMasterDetailStrategy(
                                             x => x.GetType().GetCustomAttribute <MasterAttribute>(true) != null,
                                             x => x.GetType().GetCustomAttribute <DetailAttribute>(true) != null,
                                             (master, detail) => ((MasterRecord)master).DetailRecords.Add((DetailRecord)detail)));
        }
Ejemplo n.º 2
0
        public DelimitedMultiEngineTests()
        {
            var factory = new DelimitedFileEngineFactory();
            var types   = new System.Collections.Generic.List <Type>()
            {
                typeof(Record1),
                typeof(Record2)
            };

            engine = factory.GetEngine(types.AsEnumerable <Type>(),
                                       s =>
            {
                if (String.IsNullOrEmpty(s) || s.Length < 1)
                {
                    return(null);
                }

                switch (s[0])
                {
                case 'S':
                    return(typeof(Record1));

                case 'D':
                    return(typeof(Record2));

                default:
                    return(null);
                }
            }
                                       );
        }
        public FixedLengthMultiEngineTests()
        {
            var layouts = new List <ILayoutDescriptor <IFixedFieldSettingsContainer> > {
                new Record1Layout(), new Record2Layout()
            };

            engine = new FixedLengthFileMultiEngine(layouts,
                                                    (s, i) =>
            {
                if (String.IsNullOrEmpty(s) || s.Length < 1)
                {
                    return(null);
                }

                switch (s[0])
                {
                case 'S':
                    return(typeof(Record1));

                case 'D':
                    return(typeof(Record2));

                default:
                    return(null);
                }
            },
                                                    new FixedLengthLineBuilderFactory(),
                                                    new FixedLengthLineParserFactory())
            {
                HasHeader = true
            };
        }
        public DelimitedMasterDetailTests()
        {
            _engine = _factory.GetEngine(new IDelimitedLayoutDescriptor[] { new MasterRecordLayout(), new DetailRecordLayout() },
                                         (line, number) =>
            {
                if (String.IsNullOrEmpty(line) || line.Length < 1)
                {
                    return(null);
                }

                return((line[0]) switch
                {
                    'M' => typeof(MasterRecord),
                    'D' => typeof(DetailRecord),
                    _ => null,
                });
            });
        public DelimitedMasterDetailCustomTests()
        {
            _engine = _factory.GetEngine(new [] { typeof(MasterRecord), typeof(DetailRecord) },
                                         (line, number) =>
            {
                if (String.IsNullOrEmpty(line) || line.Length < 1)
                {
                    return(null);
                }

                return((line[0]) switch
                {
                    'M' => typeof(MasterRecord),
                    'D' => typeof(DetailRecord),
                    _ => null,
                });
            },
        public FixedLengthMasterDetailCustomTests()
        {
            var layouts = new List <IFixedLengthLayoutDescriptor>
            {
                new HeaderLayout(),
                new HeaderContinuationLayout(),
                new DetailLayout(),
                new StandaloneLayout()
            };

            engine = new FixedLengthFileMultiEngine(layouts,
                                                    (s, i) =>
            {
                if (String.IsNullOrEmpty(s) || s.Length < 1)
                {
                    return(null);
                }

                switch (s[0])
                {
                case 'H':
                    return(typeof(HeaderRecord));

                case 'M':
                    return(typeof(HeaderRecordContinuation));

                case 'S':
                    return(typeof(StandaloneRecord));

                case 'D':
                    return(typeof(DetailRecord));

                default:
                    return(null);
                }
            },
                                                    new FixedLengthLineBuilderFactory(),
                                                    new FixedLengthLineParserFactory(),
                                                    new DelegatingMasterDetailStrategy(
                                                        x => x.GetType().GetCustomAttribute <MasterAttribute>(true) != null,
                                                        x => x.GetType().GetCustomAttribute <DetailAttribute>(true) != null,
                                                        (master, detail) => ((HeaderRecord)master).DetailRecords.Add((DetailRecord)detail)));
        }
        public FixedLengthMasterDetailTests()
        {
            var layouts = new List <IFixedLengthLayoutDescriptor>
            {
                new HeaderLayout(),
                new HeaderContinuationLayout(),
                new DetailLayout(),
                new StandaloneLayout()
            };

            engine = new FixedLengthFileMultiEngine(layouts,
                                                    (s, i) =>
            {
                if (String.IsNullOrEmpty(s) || s.Length < 1)
                {
                    return(null);
                }

                switch (s[0])
                {
                case 'H':
                    return(typeof(HeaderRecord));

                case 'M':
                    return(typeof(HeaderRecordContinuation));

                case 'S':
                    return(typeof(StandaloneRecord));

                case 'D':
                    return(typeof(DetailRecord));

                default:
                    return(null);
                }
            },
                                                    new FixedLengthLineBuilderFactory(),
                                                    new FixedLengthLineParserFactory(),
                                                    new DefaultFixedLengthMasterDetailStrategy());
        }
        public FixedLengthMasterDetailTests()
        {
            var layouts = new List <IFixedLengthLayoutDescriptor>
            {
                new HeaderLayout(),
                new HeaderContinuationLayout(),
                new DetailLayout(),
                new StandaloneLayout()
            };

            engine = new FixedLengthFileMultiEngine(layouts,
                                                    (s, i) =>
            {
                return(s?.FirstOrDefault() switch
                {
                    'H' => typeof(HeaderRecord),
                    'M' => typeof(HeaderRecordContinuation),
                    'S' => typeof(StandaloneRecord),
                    'D' => typeof(DetailRecord),
                    _ => null,
                });
            },
        public DelimitedMasterDetailTests()
        {
            _engine = _factory.GetEngine(new IDelimitedLayoutDescriptor[] { new MasterRecordLayout(), new DetailRecordLayout() },
                                         (line, number) =>
            {
                if (String.IsNullOrEmpty(line) || line.Length < 1)
                {
                    return(null);
                }

                switch (line[0])
                {
                case 'M':
                    return(typeof(MasterRecord));

                case 'D':
                    return(typeof(DetailRecord));

                default:
                    return(null);
                }
            });
        }