-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
Copy pathProjectKey.cs
34 lines (28 loc) · 1.21 KB
/
ProjectKey.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BuildBoss
{
internal readonly struct ProjectKey : IEquatable<ProjectKey>
{
internal string FilePath { get; }
internal string FileName => FilePath != null ? Path.GetFileName(FilePath) : "";
internal ProjectKey(string filePath)
{
FilePath = Path.GetFullPath(filePath);
}
public static bool operator ==(ProjectKey left, ProjectKey right) => StringComparer.OrdinalIgnoreCase.Equals(left.FilePath, right.FilePath);
public static bool operator !=(ProjectKey left, ProjectKey right) => !(left == right);
public bool Equals(ProjectKey other) => other == this;
public override bool Equals(object obj) => obj is ProjectKey && Equals((ProjectKey)obj);
public override int GetHashCode() => FilePath?.GetHashCode() ?? 0;
public override string ToString() => FileName;
}
}