-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackgroundCopyFileRange.cs
111 lines (86 loc) · 3.26 KB
/
BackgroundCopyFileRange.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//
// @(#) BackgroundCopyFileRange.cs
//
// Project: usis.Net.Bits
// System: Microsoft Visual Studio 2017
// Author: Udo Schäfer
//
// Copyright (c) 2018 usis GmbH. All rights reserved.
using System;
using System.Globalization;
using usis.Net.Bits.Interop;
namespace usis.Net.Bits
{
// -----------------------------
// BackgroundCopyFileRange class
// -----------------------------
/// <summary>
/// Identifies a range of bytes to download from a file.
/// </summary>
public sealed class BackgroundCopyFileRange
{
#region construction
// ------------
// construction
// ------------
/// <summary>
/// Initializes a new instance of the <see cref="BackgroundCopyFileRange"/> class
/// with the specified offset and length.
/// </summary>
/// <param name="offset">The offset to the beginning of the range of bytes to download from a file.</param>
/// <param name="length">The length of the range, in bytes.</param>
public BackgroundCopyFileRange(long offset, long length) { Offset = offset; Length = length; }
internal BackgroundCopyFileRange(BG_FILE_RANGE range)
{
Offset = Convert.ToInt64(range.InitialOffset);
Length = range.Length == Interop.Constants.BG_LENGTH_TO_EOF ? Constants.LengthToEndOfFile : Convert.ToInt64(range.Length);
}
#endregion construction
#region properties
// ---------------
// Offset property
// ---------------
/// <summary>
/// Gets or sets the offset to the beginning of the range of bytes to download from a file.
/// </summary>
/// <value>
/// The zero-based offset to the beginning of the range of bytes to download from a file.
/// </value>
public long Offset { get; set; }
// ---------------
// Length property
// ---------------
/// <summary>
/// Gets or sets the length of the range, in bytes.
/// </summary>
/// <value>
/// The length of the range, in bytes.
/// </value>
public long Length { get; }
#endregion properties
#region methods
// ------------------
// ToFileRange method
// ------------------
internal BG_FILE_RANGE ToFileRange()
{
return new BG_FILE_RANGE()
{
InitialOffset = Convert.ToUInt64(Offset),
Length = Length == Constants.LengthToEndOfFile ? Interop.Constants.BG_LENGTH_TO_EOF : Convert.ToUInt64(Length)
};
}
// ---------------
// ToString method
// ---------------
/// <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() => string.Format(CultureInfo.InvariantCulture, "Range: Offset={0}, Length={1}", Offset, Length);
#endregion methods
}
}
// eof "BackgroundCopyFileRange.cs"