Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vs-editor-api.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/Def/ImageId.cs')
-rw-r--r--src/Core/Def/ImageId.cs25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/Core/Def/ImageId.cs b/src/Core/Def/ImageId.cs
index d540c16..0f7486f 100644
--- a/src/Core/Def/ImageId.cs
+++ b/src/Core/Def/ImageId.cs
@@ -2,6 +2,8 @@
{
using System;
+#pragma warning disable CA1720 // Identifier contains type name
+#pragma warning disable CA1051 // Do not declare visible instance fields
/// <summary>
/// Unique identifier for Visual Studio image asset.
/// </summary>
@@ -9,7 +11,7 @@
/// On Windows systems, <see cref="ImageId"/> can be converted to and from
/// various other image representations via the ImageIdExtensions extension methods.
/// </remarks>
- public struct ImageId
+ public struct ImageId : IEquatable<ImageId>
{
/// <summary>
/// The <see cref="Guid"/> identifying the group to which this image belongs.
@@ -31,5 +33,26 @@
this.Guid = guid;
this.Id = id;
}
+ public override string ToString()
+ {
+ return this.ToString(System.Globalization.CultureInfo.InvariantCulture);
+ }
+
+ public string ToString(IFormatProvider provider)
+ {
+ return string.Format(provider, @"{0} : {1}", this.Guid.ToString("D", provider), Id.ToString(provider));
+ }
+
+ bool IEquatable<ImageId>.Equals(ImageId other) => Id.Equals(other.Id) && Guid.Equals(other.Guid);
+
+ public override bool Equals(object other) => other is ImageId otherImage && ((IEquatable<ImageId>)this).Equals(otherImage);
+
+ public static bool operator ==(ImageId left, ImageId right) => left.Equals(right);
+
+ public static bool operator !=(ImageId left, ImageId right) => !(left == right);
+
+ public override int GetHashCode() => Guid.GetHashCode() ^ Id.GetHashCode();
}
+#pragma warning restore CA1720 // Identifier contains type name
+#pragma warning restore CA1051 // Do not declare visible instance fields
}