public BytesContent(byte[] content, int offset, int count) { if (content == null) { throw new ArgumentNullException(nameof(content)); } if (offset < 0) { throw ExceptionHelper.CanNotBeLess <int>(nameof(offset), 0); } if (offset > content.Length) { throw ExceptionHelper.CanNotBeGreater <int>(nameof(offset), content.Length); } if (count < 0) { throw ExceptionHelper.CanNotBeLess <int>(nameof(count), 0); } if (count > content.Length - offset) { throw ExceptionHelper.CanNotBeGreater <int>(nameof(count), content.Length - offset); } this._content = content; this._offset = offset; this._count = count; this._contentType = "application/octet-stream"; }
/// <summary> /// Инициализирует новый экземпляр класса <see cref="MultipartContent"/>. /// </summary> /// <param name="boundary">Граница для отделения составных частей содержимого.</param> /// <exception cref="System.ArgumentNullException">Значение параметра <paramref name="boundary"/> равно <see langword="null"/>.</exception> /// <exception cref="System.ArgumentException">Значение параметра <paramref name="boundary"/> является пустой строкой.</exception> /// <exception cref="System.ArgumentOutOfRangeException">Значение параметра <paramref name="boundary"/> имеет длину более 70 символов.</exception> public MultipartContent(string boundary) { #region Проверка параметров if (boundary == null) { throw new ArgumentNullException("boundary"); } if (boundary.Length == 0) { throw ExceptionHelper.EmptyString("boundary"); } if (boundary.Length > 70) { throw ExceptionHelper.CanNotBeGreater("boundary", 70); } #endregion _boundary = boundary; _contentType = string.Format("multipart/form-data; boundary={0}", _boundary); }
public MultipartContent(string boundary) { if (boundary == null) { throw new ArgumentNullException(nameof(boundary)); } if (boundary.Length == 0) { throw ExceptionHelper.EmptyString(nameof(boundary)); } if (boundary.Length > 70) { throw ExceptionHelper.CanNotBeGreater <int>(nameof(boundary), 70); } this._boundary = boundary; this._contentType = string.Format("multipart/form-data; boundary={0}", (object)this._boundary); }
/// <summary> /// Инициализирует новый экземпляр класса <see cref="BytesContent"/>. /// </summary> /// <param name="content">Содержимое тела запроса.</param> /// <param name="offset">Смещение в байтах для контента.</param> /// <param name="count">Число байтов отправляемых из контента.</param> /// <exception cref="System.ArgumentNullException">Значение параметра <paramref name="content"/> равно <see langword="null"/>.</exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// Значение параметра <paramref name="offset"/> меньше 0. /// -или- /// Значение параметра <paramref name="offset"/> больше длины содержимого. /// -или- /// Значение параметра <paramref name="count"/> меньше 0. /// -или- /// Значение параметра <paramref name="count"/> больше (длина содержимого - смещение).</exception> /// <remarks>По умолчанию используется тип контента - 'application/octet-stream'.</remarks> public BytesContent(byte[] content, int offset, int count) { #region Проверка параметров if (content == null) { throw new ArgumentNullException("content"); } if (offset < 0) { throw ExceptionHelper.CanNotBeLess("offset", 0); } if (offset > content.Length) { throw ExceptionHelper.CanNotBeGreater("offset", content.Length); } if (count < 0) { throw ExceptionHelper.CanNotBeLess("count", 0); } if (count > (content.Length - offset)) { throw ExceptionHelper.CanNotBeGreater("count", content.Length - offset); } #endregion _content = content; _offset = offset; _count = count; _contentType = "application/octet-stream"; }