-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into extend-aws-policy
- Loading branch information
Showing
11 changed files
with
341 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models | ||
{ | ||
using System; | ||
using LEGO.AsyncAPI.Models.Interfaces; | ||
|
||
public static class BindingExtensions | ||
{ | ||
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IServerBinding> bindings, out TBinding binding) | ||
where TBinding : class, IServerBinding | ||
{ | ||
if (bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out var serverBinding)) | ||
{ | ||
binding = serverBinding as TBinding; | ||
return true; | ||
} | ||
|
||
binding = default; | ||
return false; | ||
} | ||
|
||
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IChannelBinding> bindings, out TBinding binding) | ||
where TBinding : class, IChannelBinding | ||
{ | ||
if (bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out var channelBinding)) | ||
{ | ||
binding = channelBinding as TBinding; | ||
return true; | ||
} | ||
|
||
binding = default; | ||
return false; | ||
} | ||
|
||
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IOperationBinding> bindings, out TBinding binding) | ||
where TBinding : class, IOperationBinding | ||
{ | ||
if (bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out var operationBinding)) | ||
{ | ||
binding = operationBinding as TBinding; | ||
return true; | ||
} | ||
|
||
binding = default; | ||
return false; | ||
} | ||
|
||
public static bool TryGetValue<TBinding>(this AsyncApiBindings<IMessageBinding> bindings, out TBinding binding) | ||
where TBinding : class, IMessageBinding | ||
{ | ||
if (bindings.TryGetValue(Activator.CreateInstance<TBinding>().BindingKey, out var messageBinding)) | ||
{ | ||
binding = messageBinding as TBinding; | ||
return true; | ||
} | ||
|
||
binding = default; | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.