private string GetIdHint(IdHinter second)
        {
            if (ShouldReturnIdHint(second, this))
                return second.GetIdHint();

            return ShouldReturnIdHint(this, second) ? GetIdHint() : null;
        }
        /// <summary>
        /// Gets the id hint. Only returns an Id if <paramref name="constraint"/> is an <see cref="AttributeConstraint"/> on an exact Id or
        /// if the <paramref name="constraint"/> is an <see cref="AndConstraint"/> with an <see cref="AttributeConstraint"/> on an exact Id 
        /// and an <see cref="AnyConstraint"/>.
        /// </summary>
        /// <param name="constraint">The constraint to get the id Hint from.</param>
        /// <returns></returns>
        public static string GetIdHint(Constraint constraint)
        {
            var andConstraint = constraint as AndConstraint;
            if (andConstraint != null)
            {
                var left = new IdHinter(andConstraint.First);
                var right = new IdHinter(andConstraint.Second);

                return left.GetIdHint(right);
            }

            return new IdHinter(constraint).GetIdHint();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the id hint. Only returns an Id if <paramref name="constraint"/> is an <see cref="AttributeConstraint"/> on an exact Id or
        /// if the <paramref name="constraint"/> is an <see cref="AndConstraint"/> with an <see cref="AttributeConstraint"/> on an exact Id
        /// and an <see cref="AnyConstraint"/>.
        /// </summary>
        /// <param name="constraint">The constraint to get the id Hint from.</param>
        /// <returns></returns>
        public static string GetIdHint(Constraint constraint)
        {
            var andConstraint = constraint as AndConstraint;

            if (andConstraint != null)
            {
                var left  = new IdHinter(andConstraint.First);
                var right = new IdHinter(andConstraint.Second);

                return(left.GetIdHint(right));
            }

            return(new IdHinter(constraint).GetIdHint());
        }
 private static bool ShouldReturnIdHint(IdHinter of, IdHinter constraint)
 {
     return of.HasId && (constraint.IsAllowedConstraint & !constraint.HasId);
 }
Exemplo n.º 5
0
 /// <summary>
 /// If the constraint can only match on element with a particular id, returns the id,
 /// otherwise returns null.
 /// </summary>
 /// <returns>The id or null if the constraint could match elements with no particular id</returns>
 protected virtual string GetElementIdHint(Constraint constraint)
 {
     return(IdHinter.GetIdHint(constraint));
 }
Exemplo n.º 6
0
 private static bool ShouldReturnIdHint(IdHinter of, IdHinter constraint)
 {
     return(of.HasId && (constraint.IsAllowedConstraint & !constraint.HasId));
 }