<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0-beta.2" />

ContentRange

struct ContentRange
using Azure.Core; using System; using System.ComponentModel; using System.Globalization; using System.Runtime.CompilerServices; namespace Azure.Storage { internal struct ContentRange { public struct RangeUnit { internal const string BytesValue = "bytes"; private readonly string _value; public static RangeUnit Bytes { get; } = new RangeUnit("bytes"); public RangeUnit(string value) { if (value == null) throw new ArgumentNullException("value"); _value = value; } public static bool operator ==(RangeUnit left, RangeUnit right) { return left.Equals(right); } public static bool operator !=(RangeUnit left, RangeUnit right) { return !left.Equals(right); } public static implicit operator RangeUnit(string value) { return new RangeUnit(value); } [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) { if (obj is RangeUnit) { RangeUnit other = (RangeUnit)obj; return Equals(other); } return false; } public bool Equals(RangeUnit other) { return string.Equals(_value, other._value, StringComparison.Ordinal); } [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() { return _value?.GetHashCode() ?? 0; } public override string ToString() { return _value; } } private const string WildcardMarker = "*"; public long? Start { [IsReadOnly] get; } public long? End { [IsReadOnly] get; } public long? Size { [IsReadOnly] get; } public RangeUnit Unit { [IsReadOnly] get; } public ContentRange(RangeUnit unit, long? start, long? end, long? size) { Start = start; End = end; Size = size; Unit = unit; } public static ContentRange Parse(string headerValue) { string[] array = headerValue.Split(' ', '-', '/'); long? start = null; long? end = null; long? size = null; try { string value = array[0]; int num; if (array[1] == "*") num = 2; else { num = 3; start = long.Parse(array[1], CultureInfo.InvariantCulture); end = long.Parse(array[2], CultureInfo.InvariantCulture); } string text = array[num]; if (text != "*") size = long.Parse(text, CultureInfo.InvariantCulture); return new ContentRange(value, start, end, size); } catch (IndexOutOfRangeException) { throw Errors.ParsingHttpRangeFailed(); } } public static HttpRange ToHttpRange(ContentRange contentRange) { if (contentRange.Start.HasValue) return new HttpRange(contentRange.Start.Value, (long?)(contentRange.End.Value + 1)); return default(HttpRange); } [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) { if (obj is RangeUnit) { RangeUnit rangeUnit = (RangeUnit)obj; return Equals(rangeUnit); } return false; } public bool Equals(ContentRange other) { long? start = other.Start; long? start2 = Start; if ((start.GetValueOrDefault() == start2.GetValueOrDefault()) & (start.HasValue == start2.HasValue)) { start2 = other.End; start = End; if (((start2.GetValueOrDefault() == start.GetValueOrDefault()) & (start2.HasValue == start.HasValue)) && other.Unit == Unit) { start = other.Size; start2 = Size; return (start.GetValueOrDefault() == start2.GetValueOrDefault()) & (start.HasValue == start2.HasValue); } } return false; } public static bool operator ==(ContentRange left, ContentRange right) { return left.Equals(right); } public static bool operator !=(ContentRange left, ContentRange right) { return !left.Equals(right); } [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() { return HashCodeBuilder.Combine(Start, End, Size, Unit.GetHashCode()); } } }