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
31 lines (25 loc) · 1018 Bytes
/
NpgsqlDatabaseInfoCacheKey.cs
File metadata and controls
31 lines (25 loc) · 1018 Bytes
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
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() =>
HashCode.Combine(Port, Host, Database, CompatibilityMode);
}