Ejemplo n.º 1
0
        private string GetIdHint(IdHinter second)
        {
            if (ShouldReturnIdHint(second, this))
                return second.GetIdHint();

            return ShouldReturnIdHint(this, second) ? GetIdHint() : null;
        }
Ejemplo n.º 2
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();
        }
Ejemplo 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());
        }
Ejemplo n.º 4
0
 private static bool ShouldReturnIdHint(IdHinter of, IdHinter constraint)
 {
     return of.HasId && (constraint.IsAllowedConstraint & !constraint.HasId);
 }
Ejemplo 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));
 }
Ejemplo n.º 6
0
 private static bool ShouldReturnIdHint(IdHinter of, IdHinter constraint)
 {
     return(of.HasId && (constraint.IsAllowedConstraint & !constraint.HasId));
 }