/// <summary>
        /// Initializes a new instance of the <see cref="BinarySelectorElement"/> class.
        /// </summary>
        public BinarySelectorElement(SelectorElementBase left, SelectorElementBase right, CombinatorElementBase combinatorElement)
        {
            Assume.NotNull(left, nameof(left));
            Assume.NotNull(right, nameof(right));
            Assume.NotNull(combinatorElement, nameof(combinatorElement));

            Left              = left;
            Right             = right;
            CombinatorElement = combinatorElement;
        }
Esempio n. 2
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <returns>
 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 /// <param name="other">An object to compare with this object.</param>
 public Boolean Equals(CombinatorElementBase other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(String.Equals(Value, other.Value));
 }
Esempio n. 3
0
        /// <summary>
        /// Resolves the CombinatorElement.
        /// </summary>
        private BinaryCombinator resolveCombinator(CombinatorElementBase combinatorElement, CombinatorBase left, CombinatorBase right)
        {
            var combinators = DescriptorRepository.GetCombinatorDescriptors()
                              .Where(combinator => NameMatcher.Match(combinator.Value, combinatorElement.Value))
                              .ToArray();

            if (combinators.Count() > 1)
            {
                throw new Exception($"Ambiguity of combinator element: {combinatorElement.Value}");
            }

            if (!combinators.Any())
            {
                throw new Exception($"Combinator is not found: {combinatorElement.Value}");
            }

            return(SelectorFactory.CreateCombinator(combinators[0].CombinatorType, left, right));
        }