Ejemplo n.º 1
0
 /// <summary>
 /// Sets a property setter object to configure the <see cref="RapideFix.Parsers.IMessageParser{TOutput, TData}"/> instances built by ParserBuilder.
 /// </summary>
 /// <returns>The builder instance.</returns>
 public ParserBuilder <TOutput> SetPropertySetter(ITypedPropertySetter propertySetter)
 {
     if (_propertySetter != null)
     {
         throw new ArgumentException("Property Setter is already set");
     }
     _propertySetter = propertySetter ?? throw new ArgumentNullException(nameof(propertySetter));
     return(this);
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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");
        }