Beispiel #1
0
        /// <summary>
        /// Validates and parses the provided market specifiers
        /// </summary>
        /// <param name="message">The <see cref="FeedMessage"/> instance containing the market whose specifiers are being validated</param>
        /// <param name="market">A <see cref="FeedMarket"/> instance containing the specifiers to validate</param>
        /// <param name="marketIndex">The index of the <code>market</code> in the <code>message</code></param>
        private static bool ValidateSpecifiers(FeedMessage message, FeedMarket market, int marketIndex)
        {
            Contract.Requires(message != null);
            Contract.Requires(market != null);
            Contract.Requires(marketIndex >= 0);

            if (string.IsNullOrEmpty(market.SpecifierString))
            {
                return(true);
            }

            try
            {
                market.Specifiers = FeedMapperHelper.GetSpecifiers(market.SpecifierString);
                return(true);
            }
            catch (Exception ex)
            {
                if (ex is FormatException || ex is ArgumentException)
                {
                    market.ValidationFailed = true;
                    LogWarning(message, $"markets[{marketIndex}].specifiers", market.SpecifierString);
                    return(false);
                }
                throw;
            }
        }
        /// <summary>
        /// Validates and parses the provided market specifiers
        /// </summary>
        /// <param name="message">The <see cref="FeedMessage"/> instance containing the market whose specifiers are being validated</param>
        /// <param name="market">A <see cref="FeedMarket"/> instance containing the specifiers to validate</param>
        /// <param name="marketIndex">The index of the <code>market</code> in the <code>message</code></param>
        private static bool ValidateSpecifiers(FeedMessage message, FeedMarket market, int marketIndex)
        {
            Guard.Argument(message, nameof(message)).NotNull();
            Guard.Argument(market, nameof(market)).NotNull();
            Guard.Argument(marketIndex).NotNegative();

            if (string.IsNullOrEmpty(market.SpecifierString))
            {
                return(true);
            }

            try
            {
                market.Specifiers = FeedMapperHelper.GetSpecifiers(market.SpecifierString);
                return(true);
            }
            catch (Exception ex)
            {
                if (ex is FormatException || ex is ArgumentException)
                {
                    market.ValidationFailed = true;
                    LogWarning(message, $"markets[{marketIndex}].specifiers", market.SpecifierString);
                    return(false);
                }
                throw;
            }
        }