public static TypeArgumentSpecification Named(this TypeArgumentSpecification @this, string name) { Guard.NotNull(@this, "this"); Guard.NotNullOrWhiteSpace(name, "name"); return(@this.Combine(x => Outcome.FailIf(x.Name != name, String.Format("Not named '{0}'.", name)))); }
public static TypeArgumentSpecification Type(this TypeArgumentSpecification @this, Func <Type, TypeSpecification, TypeSpecification> typeSpecification) { Guard.NotNull(@this, "this"); Guard.NotNull(typeSpecification, "typeSpecification"); return(@this.Combine(ta => typeSpecification(ta, TypeSpecificationBuilder.Any)(ta))); }
public static TypeArgumentSpecification Combine(this TypeArgumentSpecification left, TypeArgumentSpecification right) { if (left == Any) { return(right); } if (right == Any) { return(left); } if (left == null || right == null) { return(left ?? right); } return(x => { var leftOutcome = left(x); return leftOutcome.WasSuccessful ? leftOutcome & right(x) : leftOutcome; }); }
public static TypeArgumentSpecification MustBeReferenceType(this TypeArgumentSpecification @this) { Guard.NotNull(@this, "this"); return(@this.Combine(ta => Outcome.FailIf(!ta.GenericParameterAttributes.Contains(GenericParameterAttributes.ReferenceTypeConstraint), "Cannot be reference type."))); }
public static TypeArgumentSpecification AtIndex(this TypeArgumentSpecification @this, int index) { Guard.NotNull(@this, "this"); return(@this.Combine(x => Outcome.FailIf(x.GenericParameterPosition != index, "Not at correct index."))); }
public static TypeArgumentSpecification Combine(this TypeArgumentSpecification left, TypeArgumentSpecification right) { if (left == Any) return right; if (right == Any) return left; if (left == null || right == null) return left ?? right; return x => { var leftOutcome = left(x); return leftOutcome.WasSuccessful ? leftOutcome & right(x) : leftOutcome; }; }