-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathOpcItemEqualityComparer.cs
More file actions
31 lines (27 loc) · 1.03 KB
/
OpcItemEqualityComparer.cs
File metadata and controls
31 lines (27 loc) · 1.03 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
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
namespace BootstrapBlazor.OpcDa;
/// <summary>
/// <see cref="IOpcItem"/> 比较器
/// </summary>
public class OpcItemEqualityComparer<TItem> : IEqualityComparer<TItem> where TItem : IOpcItem
{
/// <summary>
/// 获得 <see cref="OpcItemEqualityComparer{TItem}"/> 实例
/// </summary>
public static OpcItemEqualityComparer<TItem> Default { get; } = new();
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public bool Equals(TItem? x, TItem? y) => x?.Name == y?.Name;
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public int GetHashCode([DisallowNull] TItem item) => item.Name.GetHashCode();
}