Beispiel #1
0
 /// <summary>
 /// A constraint that can be used to check if two parameters do not contain the same value
 /// </summary>
 /// <param name="namedParam1">The first named parameter being checked for equality</param>
 /// <param name="namedParam2">The other named parameter being checked for equality</param>
 /// <returns>True if one of the parameters is not present in the substitution or if the values of both parameters are equal, false otherwise</returns>
 public static Func <Dictionary <string, object>, bool> NotEqualsCheck(NamedParameter namedParam1, NamedParameter namedParam2)
 {
     return((tuples) => !tuples.ContainsKey(namedParam1.Name) || !tuples.ContainsKey(namedParam2.Name) ||
            (tuples[namedParam1.Name] == null && tuples[namedParam2.Name] == null) ||
            (tuples[namedParam1.Name] != null && !tuples[namedParam1.Name].Equals(tuples[namedParam2.Name])));
 }
Beispiel #2
0
 /// <summary>
 /// A constraint that can be used to check if a the value of a parameter is of a certain type
 /// </summary>
 /// <param name="expectedType">The expected type of the value of a parameter</param>
 /// <param name="namedParameter">The named parameter being checked</param>
 /// <returns>A function that returns true if the value in the substitution corresponding to the given name is of the expected type, false otherwise</returns>
 public static Func <Dictionary <string, object>, bool> TypeCheck(Type expectedType, NamedParameter namedParameter)
 {
     return((tuples) => !tuples.ContainsKey(namedParameter.Name) || (tuples[namedParameter.Name] != null && tuples[namedParameter.Name].GetType().Equals(expectedType)));
 }