Esempio n. 1
0
        /// <summary>
        /// Gets a <see cref="IList{INameExpression}"/> constructed from the provided descriptor
        /// </summary>
        /// <param name="nameDescriptor">The name descriptor</param>
        /// <param name="nameDescriptorFormat">When the call completes, the <code>nameDescriptor</code> replaced with string format placeholders</param>
        /// <returns>a <see cref="IList{INameExpression}"/> constructed from the provided descriptor</returns>
        /// <exception cref="FormatException">Provided <code>nameDescriptor</code> couldn't be parsed due to incorrect format</exception>
        /// <exception cref="ArgumentException">One of the operators specified in the <code>nameDescriptor</code> is not supported</exception>
        protected IList <INameExpression> GetNameExpressions(string nameDescriptor, out string nameDescriptorFormat)
        {
            Guard.Argument(nameDescriptor, nameof(nameDescriptor)).NotNull().NotEmpty();

            var expressionStrings = NameExpressionHelper.ParseDescriptor(nameDescriptor, out nameDescriptorFormat);

            if (expressionStrings == null)
            {
                return(null);
            }

            var expressions = new List <INameExpression>(expressionStrings.Count);

            foreach (var expression in expressionStrings)
            {
                string @operator; // can be null
                string operand;   // cannot be null
                NameExpressionHelper.ParseExpression(expression, out @operator, out operand);
                expressions.Add(_expressionFactory.BuildExpression(_sportEvent, _specifiers, @operator, operand));
            }
            return(expressions);
        }
        /// <summary>
        /// Gets a <see cref="IList{INameExpression}"/> constructed from the provided descriptor
        /// </summary>
        /// <param name="nameDescriptor">The name descriptor</param>
        /// <param name="nameDescriptorFormat">When the call completes, the <code>nameDescriptor</code> replaced with string format placeholders</param>
        /// <returns>a <see cref="IList{INameExpression}"/> constructed from the provided descriptor</returns>
        /// <exception cref="FormatException">Provided <code>nameDescriptor</code> couldn't be parsed due to incorrect format</exception>
        /// <exception cref="ArgumentException">One of the operators specified in the <code>nameDescriptor</code> is not supported</exception>
        protected IList <INameExpression> GetNameExpressions(string nameDescriptor, out string nameDescriptorFormat)
        {
            Contract.Requires(!string.IsNullOrEmpty(nameDescriptor));
            Contract.Ensures(!string.IsNullOrEmpty(Contract.ValueAtReturn(out nameDescriptorFormat)));

            var expressionStrings = NameExpressionHelper.ParseDescriptor(nameDescriptor, out nameDescriptorFormat);

            if (expressionStrings == null)
            {
                return(null);
            }

            var expressions = new List <INameExpression>(expressionStrings.Count);

            foreach (var expression in expressionStrings)
            {
                string @operator; // can be null
                string operand;   // cannot be null
                NameExpressionHelper.ParseExpression(expression, out @operator, out operand);
                expressions.Add(_expressionFactory.BuildExpression(_sportEvent, _specifiers, @operator, operand));
            }
            return(expressions);
        }