forked from testcontainers/testcontainers-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectoryPath.cs
More file actions
55 lines (49 loc) · 1.37 KB
/
DirectoryPath.cs
File metadata and controls
55 lines (49 loc) · 1.37 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
namespace DotNet.Testcontainers.Builders
{
using System;
using DotNet.Testcontainers.Configurations;
using JetBrains.Annotations;
/// <summary>
/// Represents a container or host directory path.
/// </summary>
[PublicAPI]
public readonly record struct DirectoryPath
{
/// <summary>
/// Initializes a new instance of the <see cref="DirectoryPath" /> struct.
/// </summary>
/// <param name="value">The directory path value.</param>
private DirectoryPath(string value)
{
Value = value;
}
/// <summary>
/// Gets the normalized directory path value.
/// </summary>
[PublicAPI]
public string Value { get; }
/// <summary>
/// Creates a new <see cref="DirectoryPath" /> from the specified path.
/// </summary>
/// <param name="path">The directory path.</param>
/// <returns>The normalized <see cref="DirectoryPath" />.</returns>
[PublicAPI]
public static DirectoryPath Of(string path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("The directory path cannot be empty.", nameof(path));
}
return new DirectoryPath(Unix.Instance.NormalizePath(path));
}
/// <inheritdoc />
public override string ToString()
{
return Value;
}
}
}