forked from npgsql/npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNpgsqlDatabaseInfoCacheKey.cs
More file actions
35 lines (30 loc) · 1.17 KB
/
NpgsqlDatabaseInfoCacheKey.cs
File metadata and controls
35 lines (30 loc) · 1.17 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
using System;
namespace Npgsql
{
readonly struct NpgsqlDatabaseInfoCacheKey : IEquatable<NpgsqlDatabaseInfoCacheKey>
{
public readonly int Port;
public readonly string? Host;
public readonly string? Database;
public readonly ServerCompatibilityMode CompatibilityMode;
public NpgsqlDatabaseInfoCacheKey(NpgsqlConnectionStringBuilder connectionString)
{
Port = connectionString.Port;
Host = connectionString.Host;
Database = connectionString.Database;
CompatibilityMode = connectionString.ServerCompatibilityMode;
}
public bool Equals(NpgsqlDatabaseInfoCacheKey other) =>
Port == other.Port &&
Host == other.Host &&
Database == other.Database &&
CompatibilityMode == other.CompatibilityMode;
public override bool Equals(object? obj) =>
obj is NpgsqlDatabaseInfoCacheKey key && key.Equals(this);
public override int GetHashCode() =>
Port.GetHashCode() ^
Host?.GetHashCode() ?? 0 ^
Database?.GetHashCode() ?? 0 ^
CompatibilityMode.GetHashCode();
}
}