-
Notifications
You must be signed in to change notification settings - Fork 14
/
Range.cs
63 lines (58 loc) · 1.88 KB
/
Range.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
namespace QBittorrent.Client
{
/// <summary>
/// Torrent piece range.
/// </summary>
/// <seealso cref="System.IFormattable" />
public struct Range : IFormattable
{
/// <summary>
/// Initializes a new instance of the <see cref="Range"/> struct.
/// </summary>
/// <param name="startIndex">The start index.</param>
/// <param name="endIndex">The end index.</param>
public Range(long startIndex, long endIndex)
{
StartIndex = startIndex;
EndIndex = endIndex;
}
/// <summary>
/// Gets the start index.
/// </summary>
/// <value>
/// The start index.
/// </value>
public long StartIndex { get; }
/// <summary>
/// Gets the end index.
/// </summary>
/// <value>
/// The end index.
/// </value>
public long EndIndex { get; }
/// <summary>
/// Returns a <see cref="string" /> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="string" /> that represents this instance.
/// </returns>
public override string ToString()
{
return $"[{StartIndex}; {EndIndex}]";
}
/// <summary>
/// Returns a <see cref="string" /> that represents this instance.
/// </summary>
/// <param name="format">The format.</param>
/// <param name="formatProvider">The format provider.</param>
/// <returns>
/// A <see cref="string" /> that represents this instance.
/// </returns>
public string ToString(string format, IFormatProvider formatProvider)
{
var formatString = $"[{{0:{format}}}; {{1:{format}}}]";
return string.Format(formatProvider, formatString, StartIndex, EndIndex);
}
}
}