forked from EcovadisCode/Ev.ServiceBus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientOptionsExtensions.cs
More file actions
49 lines (46 loc) · 1.76 KB
/
ClientOptionsExtensions.cs
File metadata and controls
49 lines (46 loc) · 1.76 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using Azure.Core;
using Azure.Messaging.ServiceBus;
using Ev.ServiceBus.Abstractions.Configuration;
// ReSharper disable once CheckNamespace
namespace Ev.ServiceBus.Abstractions;
public static class ClientOptionsExtensions
{
/// <summary>
/// Sets the connection to use for this resource.
/// If no connection is set then the default connection will be used.
/// </summary>
/// <param name="options"></param>
/// <param name="connectionString"></param>
/// <param name="connectionOptions"></param>
/// <typeparam name="TOptions"></typeparam>
/// <returns></returns>
public static TOptions WithConnection<TOptions>(
this TOptions options,
string connectionString,
ServiceBusClientOptions connectionOptions)
where TOptions : ClientOptions
{
options.ConnectionSettings = new ConnectionSettings(connectionString, connectionOptions);
return options;
}
/// <summary>
/// Sets the connection to use for this resource using Azure Entra ID.
/// If no connection is set then the default connection will be used.
/// </summary>
/// <param name="options"></param>
/// <param name="fullyQualifiedNamespace"></param>
/// <param name="credentials"></param>
/// <param name="connectionOptions"></param>
/// <typeparam name="TOptions"></typeparam>
/// <returns></returns>
public static TOptions WithConnection<TOptions>(
this TOptions options,
string fullyQualifiedNamespace,
TokenCredential credentials,
ServiceBusClientOptions connectionOptions)
where TOptions : ClientOptions
{
options.ConnectionSettings = new ConnectionSettings(fullyQualifiedNamespace, credentials, connectionOptions);
return options;
}
}