Example #1
0
        /// <summary>
        /// Gets a delimited line builder.
        /// </summary>
        /// <param name="descriptor">The layout a builder is for.</param>
        /// <returns>A new delimited line builder.</returns>
        public IDelimitedLineBuilder GetBuilder(IDelimitedLayoutDescriptor descriptor)
        {
            if (!_lineBuilders.TryGetValue(descriptor.TargetType, out var builder))
            {
                builder = new DelimitedLineBuilder(descriptor);
                _lineBuilders[descriptor.TargetType] = builder;
            }

            return(builder);
        }
        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());
        }
Example #3
0
        /// <summary>
        /// Gets the parser.
        /// </summary>
        /// <param name="descriptor">The descriptor.</param>
        /// <returns>IFixedLengthLineParser.</returns>
        public IDelimitedLineParser GetParser(IDelimitedLayoutDescriptor descriptor)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (!_parsers.TryGetValue(descriptor.TargetType, out var parser))
            {
                parser = _parserRegistry.ContainsKey(descriptor.TargetType)
                    ? (IDelimitedLineParser)ReflectionHelper.CreateInstance(_parserRegistry[descriptor.TargetType], true, descriptor)
                    : new DelimitedLineParser(descriptor);

                _parsers[descriptor.TargetType] = parser;
            }

            return(parser);
        }
Example #4
0
 public IDelimitedLineParser GetParser(IDelimitedLayoutDescriptor descriptor)
 {
     return(new DelimitedLineParser(descriptor));
 }
 public IDelimitedLineParser GetParser(IDelimitedLayoutDescriptor descriptor)
 {
     return new DelimitedLineParser(descriptor);
 }
Example #6
0
 public IDelimitedLineBuilder GetBuilder(IDelimitedLayoutDescriptor descriptor)
 {
     return(new DelimitedLineBuilder(descriptor));
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of <see cref="DelimitedImmutableLayoutDescriptor"/>.
 /// </summary>
 /// <param name="existing">The descriptor to copy.</param>
 public DelimitedImmutableLayoutDescriptor(IDelimitedLayoutDescriptor existing)
     : base(existing)
 {
     Delimiter = existing.Delimiter;
     Quotes    = existing.Quotes;
 }
 public IDelimitedLineBuilder GetBuilder(IDelimitedLayoutDescriptor descriptor)
 {
     return new DelimitedLineBuilder(descriptor);
 }