forked from npgsql/npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNpgsqlConnectionProperties.cs
More file actions
35 lines (31 loc) · 1.26 KB
/
NpgsqlConnectionProperties.cs
File metadata and controls
35 lines (31 loc) · 1.26 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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using Microsoft.VisualStudio.Data.Framework.AdoDotNet;
namespace Npgsql.VSIX
{
public class NpgsqlConnectionProperties : AdoDotNetConnectionProperties
{
static readonly Dictionary<string, string[]> Synonyms;
public override bool IsComplete =>
!string.IsNullOrEmpty((string)this["Host"]) &&
!string.IsNullOrEmpty((string)this["Database"]) &&
(
(bool)this["Integrated Security"] ||
(!string.IsNullOrEmpty((string)this["Username"]) && !string.IsNullOrEmpty((string)this["Password"]))
);
public override string[] GetSynonyms(string key) => Synonyms[key];
static NpgsqlConnectionProperties()
{
Synonyms = typeof(NpgsqlConnectionStringBuilder)
.GetProperties()
.Where(p => p.GetCustomAttribute<NpgsqlConnectionStringPropertyAttribute>() != null)
.ToDictionary(
p => p.GetCustomAttribute<DisplayNameAttribute>().DisplayName,
p => p.GetCustomAttribute<NpgsqlConnectionStringPropertyAttribute>().Synonyms
);
}
}
}