-
Notifications
You must be signed in to change notification settings - Fork 160
/
RelationalServiceInfoFactory.cs
44 lines (34 loc) · 1.38 KB
/
RelationalServiceInfoFactory.cs
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
36
37
38
39
40
41
42
43
44
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
using Steeltoe.Extensions.Configuration;
namespace Steeltoe.Connector.Services;
public abstract class RelationalServiceInfoFactory : ServiceInfoFactory
{
public RelationalServiceInfoFactory(Tags tags, string scheme)
: base(tags, scheme)
{
}
public RelationalServiceInfoFactory(Tags tags, string[] schemes)
: base(tags, schemes)
{
}
public override IServiceInfo Create(Service binding)
{
var uri = GetUriFromCredentials(binding.Credentials);
if (uri == null)
{
var host = GetHostFromCredentials(binding.Credentials);
var port = GetPortFromCredentials(binding.Credentials);
var username = GetUsernameFromCredentials(binding.Credentials);
var password = GetPasswordFromCredentials(binding.Credentials);
var database = GetStringFromCredentials(binding.Credentials, "name");
if (host != null)
{
uri = new UriInfo(DefaultUriScheme, host, port, username, password, database).ToString();
}
}
return Create(binding.Name, uri);
}
public abstract IServiceInfo Create(string id, string url);
}