-
Notifications
You must be signed in to change notification settings - Fork 263
Expand file tree
/
Copy pathDriveInfoBase.cs
More file actions
65 lines (52 loc) · 2.13 KB
/
DriveInfoBase.cs
File metadata and controls
65 lines (52 loc) · 2.13 KB
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
namespace System.IO.Abstractions
{
/// <inheritdoc />
#if FEATURE_SERIALIZABLE
[Serializable]
#endif
public abstract class DriveInfoBase : IDriveInfo
{
/// <summary>
/// Base class for calling methods of <see cref="DriveInfo"/>
/// </summary>
protected DriveInfoBase(IFileSystem fileSystem)
{
FileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
}
[Obsolete("This constructor only exists to support mocking libraries.", error: true)]
internal DriveInfoBase() { }
/// <summary>
/// Exposes the underlying filesystem implementation. This is useful for implementing extension methods.
/// </summary>
public IFileSystem FileSystem { get; }
/// <inheritdoc cref="IDriveInfo.AvailableFreeSpace"/>
public abstract long AvailableFreeSpace { get; }
/// <inheritdoc cref="IDriveInfo.DriveFormat"/>
public abstract string DriveFormat { get; }
/// <inheritdoc cref="IDriveInfo.DriveType"/>
public abstract DriveType DriveType { get; }
/// <inheritdoc cref="IDriveInfo.IsReady"/>
public abstract bool IsReady { get; }
/// <inheritdoc cref="IDriveInfo.Name"/>
public abstract string Name { get; }
/// <inheritdoc cref="IDriveInfo.RootDirectory"/>
public abstract IDirectoryInfo RootDirectory { get; }
/// <inheritdoc cref="IDriveInfo.TotalFreeSpace"/>
public abstract long TotalFreeSpace { get; }
/// <inheritdoc cref="IDriveInfo.TotalSize"/>
public abstract long TotalSize { get; }
/// <inheritdoc cref="IDriveInfo.VolumeLabel"/>
public abstract string VolumeLabel { get; set; }
/// <summary>
/// Implicitly converts a <see cref="DriveInfo"/> to a <see cref="DriveInfoBase"/>.
/// </summary>
public static implicit operator DriveInfoBase(DriveInfo driveInfo)
{
if (driveInfo == null)
{
return null;
}
return new DriveInfoWrapper(new FileSystem(), driveInfo);
}
}
}