-
Notifications
You must be signed in to change notification settings - Fork 382
/
RelativeDirectoryPath.cs
65 lines (51 loc) · 1.56 KB
/
RelativeDirectoryPath.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
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.DotNet.Interactive.CSharpProject;
public class RelativeDirectoryPath :
RelativePath,
IEquatable<RelativeDirectoryPath>
{
public static RelativeDirectoryPath Root { get; } = new("./");
public RelativeDirectoryPath(string value) : base(value)
{
Value = NormalizeDirectory(value);
}
public bool Equals(RelativeDirectoryPath other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return Equals(Value, other.Value);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
if (obj.GetType() != GetType())
{
return false;
}
return Equals((RelativeDirectoryPath) obj);
}
public override int GetHashCode() => Value.GetHashCode();
public static bool operator ==(RelativeDirectoryPath left, RelativeDirectoryPath right)
{
return Equals(left, right);
}
public static bool operator !=(RelativeDirectoryPath left, RelativeDirectoryPath right)
{
return !Equals(left, right);
}
}