/// <summary> /// Throws an <see cref="NotFoundException" /> if <paramref name="input" /> with <paramref name="key" /> is not found. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="guardClause"></param> /// <param name="key"></param> /// <param name="input"></param> /// <param name="parameterName"></param> /// <returns><paramref name="input" /> if the value is not null.</returns> /// <exception cref="NotFoundException"></exception> public static T NotFound <T>([JetBrainsNotNull] this IGuardClause guardClause, [NotNull, JetBrainsNotNull][ValidatedNotNull] string key, [NotNull, JetBrainsNotNull][ValidatedNotNull] T input, [JetBrainsNotNull] string parameterName) { guardClause.NullOrEmpty(key, nameof(key)); if (input is null) { throw new NotFoundException(key, parameterName); } return(input); }
public static T NotFound <T>([JetBrainsNotNull] this IGuardClause guardClause, [NotNull, JetBrainsNotNull][ValidatedNotNull] string key, [NotNull, JetBrainsNotNull][ValidatedNotNull][JetBrainsNoEnumeration] T input, [JetBrainsNotNull][CallerArgumentExpression("input")] string?parameterName = null) #endif { guardClause.NullOrEmpty(key, nameof(key)); if (input is null) { throw new NotFoundException(key, parameterName !); } return(input); }