/// <summary> /// Initializes a new instance of the <see cref="ArgumentBuilder{T}"/> class. /// </summary> /// <param name="name">Name of the argument. It cannot be <see langword="null"/> or whitespace-only.</param> /// <exception cref="ArgumentException"><paramref name="name"/> is <see langword="null"/> or composed of only whitespaces.</exception> public ArgumentBuilder(string name) { this.name = Validations.IsValidArgumentName(name) ? name : throw Exceptions.BuildArgumentInvalidArgumentName(nameof(name)); }
/// <summary> /// Sets the <see cref="ArgumentBuilder{T}.Name"/> in the argument builder. /// </summary> /// <typeparam name="T">Type of the argument.</typeparam> /// <param name="builder">Source builder.</param> /// <param name="name">Name of the argument. It cannot be <see langword="null"/> or whitespace-only.</param> /// <returns><paramref name="builder"/>, to allow chaining.</returns> /// <exception cref="ArgumentException">The name of the argument is <see langword="null"/> or composed of only whitespaces.</exception> /// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null"/>.</exception> public static ArgumentBuilder <T> SetName <T>(this ArgumentBuilder <T> builder, string name) { (builder ?? throw Exceptions.BuildArgumentNull(nameof(builder))) .Name = Validations.IsValidArgumentName(name) ? name : throw Exceptions.BuildArgumentInvalidArgumentName(nameof(name)); return(builder); }