/// <summary> /// Constrains the <see cref="CancellationToken"/> argument to be not canceled (<c>IsCancellationRequested</c> is false). /// </summary> /// <param name="manager">The constraint manager.</param> /// <returns>A dummy argument value.</returns> public static CancellationToken IsNotCanceled(this INegatableArgumentConstraintManager <CancellationToken> manager) { Guard.AgainstNull(manager, nameof(manager)); return(manager.Matches( token => !token.IsCancellationRequested, x => x.Write("non-canceled cancellation token"))); }
public static HashSet <T> Is <T>(this INegatableArgumentConstraintManager <HashSet <T> > that, params T[]?values) { return(values == null?that.IsNull() : that.Matches(x => x.Intersect(values).Count() == values.Length)); }
public static ClrQuery Is(this INegatableArgumentConstraintManager <ClrQuery> that, string query) { return(that.Matches(x => x.ToString() == query)); }
public static Q HasIds(this INegatableArgumentConstraintManager <Q> that, IEnumerable <DomainId> ids) { return(that.Matches(x => x.Ids != null && x.Ids.SetEquals(ids.ToHashSet()))); }
public static Q HasIds(this INegatableArgumentConstraintManager <Q> that, params DomainId[] ids) { return(that.Matches(x => x.Ids != null && x.Ids.SetEquals(ids))); }
public static Q HasOData(this INegatableArgumentConstraintManager <Q> that, string odata, DomainId reference = default) { return(that.Matches(x => x.ODataQuery == odata && x.Reference == reference)); }
public static T?IsNotNull <T>(this INegatableArgumentConstraintManager <T?> manager) where T : struct { Guard.AgainstNull(manager, nameof(manager)); return(manager.Matches(x => x != null, x => x.Write("NOT NULL"))); }
/// <summary> /// Constrains an argument so that it must not be null (Nothing in VB). /// </summary> /// <typeparam name="T">The type of the argument.</typeparam> /// <param name="manager">The constraint manager to match the constraint.</param> /// <returns>A dummy argument value.</returns> public static T IsNotNull <T>(this INegatableArgumentConstraintManager <T> manager) where T : class { Guard.AgainstNull(manager, nameof(manager)); return(manager.Matches(x => x is object, x => x.Write("NOT NULL"))); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope) { Guard.AgainstNull(scope, nameof(scope)); scope.Matches(x => x == null || x == "foo", x => x.Write("string that is \"foo\" or is empty")); }
public static Q HasOData(this INegatableArgumentConstraintManager <Q> that, string query) { return(that.Matches(x => x.ODataQuery == query)); }