/// <summary> /// Match that performs the given Action if the value is the given type and /// exposes a field. /// </summary> /// <typeparam name="TCase">The type of value to match.</typeparam> /// <param name="action">The action to perform if the value matches. May be null /// in order to match and do nothing but prevent further matches.</param> /// <returns>This Matcher or a NullMatcher if the match succeeded.</returns> public ReturnMatcher <TValue, TResult> Case <TCase, TArg>(Func <TArg, TResult> action) { IMatchable <TArg> matchable = mValue as IMatchable <TArg>; return(Case(() => (matchable != null) && (mValue is TCase), () => action(matchable.GetArg()))); }
/// <summary> /// Match that performs the given Action if the value is the given type and /// exposes a field. /// </summary> /// <typeparam name="TCase">The type of value to match.</typeparam> /// <param name="action">The action to perform if the value matches. May be null /// in order to match and do nothing but prevent further matches.</param> /// <returns>This Matcher or a NullMatcher if the match succeeded.</returns> public Matcher <T> Case <TCase, TArg>(Action <TArg> action) { IMatchable <TArg> matchable = mValue as IMatchable <TArg>; return(Case(() => (matchable != null) && (mValue is TCase), () => action(matchable.GetArg()))); }