示例#1
0
        /// <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>
        /// <returns>A message parser.</returns>
        public IMessageParser <TOutput, TInput> Build <TInput>(ITagToPropertyMapper propertyMapper) where TInput : struct
        {
            var propertySetter = _propertySetter ?? new CompositePropertySetter();
            var validator      = _validator ?? new ValidatorCollection(IntegerToFixConverter.Instance);
            var options        = _options ?? new MessageParserOptions();

            return(Build <TInput>(propertyMapper, propertySetter, validator, options));
        }
示例#2
0
 /// <summary>
 /// Sets a property mapper object to configure the <see cref="RapideFix.Parsers.IMessageParser{TOutput, TData}"/> instances built by ParserBuilder.
 /// </summary>
 /// <returns>The builder instance.</returns>
 public ParserBuilder <TOutput> SetPropertyMapper(ITagToPropertyMapper propertyMapper)
 {
     if (_propertyMapper != null)
     {
         throw new ArgumentException("Property Mapper is already set");
     }
     _propertyMapper = propertyMapper ?? throw new ArgumentNullException(nameof(propertyMapper));
     return(this);
 }
示例#3
0
 public MessageParser(
     ITagToPropertyMapper tagToPropertyMapper,
     IPropertySetter compositeSetter,
     IValidator validators,
     MessageParserOptions options
     )
 {
     _propertyMapper  = tagToPropertyMapper ?? throw new ArgumentNullException(nameof(tagToPropertyMapper));
     _compositeSetter = compositeSetter ?? throw new ArgumentNullException(nameof(compositeSetter));
     _validators      = validators ?? throw new ArgumentNullException(nameof(validators));
     _options         = options ?? throw new ArgumentNullException(nameof(options));
     _messageContext  = new FixMessageContext();
 }
示例#4
0
 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;
 }
示例#5
0
        /// <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");
        }