/// <summary> /// Determines whether the parameter being validated is of a specified type. /// </summary> /// <param name="type">The type to compare against.</param> /// <returns>A new <see cref="ValidatorLinkage{ClassValidator}" /> instance of type T.</returns> /// <exception cref="ArgumentTypeException">Must be of type <paramref name="type"/>.</exception> /// <exception cref="ArgumentNullException">Thrown when the arguments are <see langword="null"/></exception> public ValidatorLinkage <ClassValidator <T> > IsOfType(Type type) { if (ShouldReturnAfterEvaluation(PerformIsOfTypeOperation(ParameterValue, type))) { return(new ValidatorLinkage <ClassValidator <T> >(this)); } if (CurrentException == null) { CurrentException = new ArgumentTypeException(string.Format(Resources.MustBeOfType, type.Name), ParameterName); } return(new ValidatorLinkage <ClassValidator <T> >(this)); }
/// <summary> /// Find all tasks that contain the specified string in their name, arglists, or documentation, and print their documentation. /// </summary> private static bool Apropos(object[] args, TextBuffer o, BindingEnvironment e, MethodCallFrame predecessor, Interpreter.Step.Continuation k) { ArgumentCountException.Check(nameof(Apropos), 1, args); var topic = ArgumentTypeException.Cast <string>(nameof(Apropos), args[0], args); var output = new StringBuilder(); bool Relevant(string x) => x != null && x.IndexOf(topic, StringComparison.InvariantCultureIgnoreCase) >= 0; var module = e.Module; foreach (var binding in module.AllBindings) { if (binding.Value is Task t && (Relevant(binding.Key.Name) || Relevant(t.Description))) { output.Append(ManualEntryMaybeRichText(t)); output.Append("\n\n"); } } return(k(o.Append(output.ToString()), e.Unifications, e.State, predecessor)); }