public TypedStringMessageParser( ITagToPropertyMapper tagToPropertyMapper, ITypedPropertySetter typedPropertySetter, IValidator validators, MessageParserOptions options ) { _propertyMapper = tagToPropertyMapper ?? throw new ArgumentNullException(nameof(tagToPropertyMapper)); _typedPropertySetter = typedPropertySetter ?? throw new ArgumentNullException(nameof(typedPropertySetter)); _options = options ?? throw new ArgumentNullException(nameof(options)); _messageContext = new FixMessageContext(); _propertyMapper.Map <TTarget>(); _isValueType = typeof(TTarget).IsValueType; }
/// <summary> /// Creates an IMessageParser object. /// </summary> /// <typeparam name="TInput">The input type of the data.</typeparam> /// <param name="propertyMapper">Custom <c>ITagToPropertyMapper</c> to this instance of the IMessageParser built.</param> /// <param name="propertySetter">Custom <c>ITypedPropertySetter</c> to this instance of the IMessageParser built.</param> /// <param name="validatorCollection">Custom <c>IValidator</c> to this instance of the IMessageParser built.</param> /// <param name="options">Custom <c>MessageParserOptions</c> to this instance of the IMessageParser built.</param> /// <returns>A message parser.</returns> public IMessageParser <TOutput, TInput> Build <TInput>(ITagToPropertyMapper propertyMapper, ITypedPropertySetter propertySetter, IValidator validatorCollection, MessageParserOptions options) { if (propertyMapper == null) { throw new ArgumentNullException(nameof(propertyMapper)); } if (propertySetter == null) { throw new ArgumentNullException(nameof(propertySetter)); } if (validatorCollection == null) { throw new ArgumentNullException(nameof(validatorCollection)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } propertyMapper.Map <TOutput>(); if (typeof(TInput) == typeof(char)) { return((IMessageParser <TOutput, TInput>) new TypedStringMessageParser <TOutput>(propertyMapper, propertySetter, validatorCollection, options)); } if (typeof(TInput) == typeof(byte)) { if (typeof(TOutput) == typeof(object)) { return((IMessageParser <TOutput, TInput>) new MessageParser(propertyMapper, propertySetter, validatorCollection, options)); } else { return((IMessageParser <TOutput, TInput>) new TypedMessageParser <TOutput>(propertyMapper, propertySetter, validatorCollection, options)); } } throw new NotSupportedException("Input type is not supported"); }