diff --git a/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaChannelBinding.cs b/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaChannelBinding.cs index b6185cd4..80e07891 100644 --- a/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaChannelBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Kafka/KafkaChannelBinding.cs @@ -4,7 +4,6 @@ namespace LEGO.AsyncAPI.Bindings.Kafka { using System; using LEGO.AsyncAPI.Models; - using LEGO.AsyncAPI.Models.Bindings.Kafka; using LEGO.AsyncAPI.Readers.ParseNodes; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI.Bindings/Kafka/TopicConfigurationObject.cs b/src/LEGO.AsyncAPI.Bindings/Kafka/TopicConfigurationObject.cs index a3fd1e7a..cbf7c955 100644 --- a/src/LEGO.AsyncAPI.Bindings/Kafka/TopicConfigurationObject.cs +++ b/src/LEGO.AsyncAPI.Bindings/Kafka/TopicConfigurationObject.cs @@ -1,9 +1,10 @@ // Copyright (c) The LEGO Group. All rights reserved. -namespace LEGO.AsyncAPI.Models.Bindings.Kafka +namespace LEGO.AsyncAPI.Bindings.Kafka { using System; using System.Collections.Generic; + using LEGO.AsyncAPI.Models; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; diff --git a/src/LEGO.AsyncAPI/Models/AsyncApiBindings.cs b/src/LEGO.AsyncAPI/Models/AsyncApiBindings.cs index d039cddf..cf382b63 100644 --- a/src/LEGO.AsyncAPI/Models/AsyncApiBindings.cs +++ b/src/LEGO.AsyncAPI/Models/AsyncApiBindings.cs @@ -7,6 +7,33 @@ namespace LEGO.AsyncAPI.Models using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; + public static class BindingExtensions + { + public static bool TryGetValue(this AsyncApiBindings bindings, out IServerBinding binding) + where TBinding : IServerBinding + { + return bindings.TryGetValue(Activator.CreateInstance().BindingKey, out binding); + } + + public static bool TryGetValue(this AsyncApiBindings bindings, out IChannelBinding binding) + where TBinding : IChannelBinding + { + return bindings.TryGetValue(Activator.CreateInstance().BindingKey, out binding); + } + + public static bool TryGetValue(this AsyncApiBindings bindings, out IOperationBinding binding) + where TBinding : IOperationBinding + { + return bindings.TryGetValue(Activator.CreateInstance().BindingKey, out binding); + } + + public static bool TryGetValue(this AsyncApiBindings bindings, out IMessageBinding binding) + where TBinding : IMessageBinding + { + return bindings.TryGetValue(Activator.CreateInstance().BindingKey, out binding); + } + } + public class AsyncApiBindings : Dictionary, IAsyncApiReferenceable where TBinding : IBinding { diff --git a/test/LEGO.AsyncAPI.Tests/Bindings/Kafka/KafkaBindings_Should.cs b/test/LEGO.AsyncAPI.Tests/Bindings/Kafka/KafkaBindings_Should.cs index 26525652..842f3c1d 100644 --- a/test/LEGO.AsyncAPI.Tests/Bindings/Kafka/KafkaBindings_Should.cs +++ b/test/LEGO.AsyncAPI.Tests/Bindings/Kafka/KafkaBindings_Should.cs @@ -2,14 +2,13 @@ namespace LEGO.AsyncAPI.Tests.Bindings.Kafka { + using System.Collections.Generic; using FluentAssertions; using LEGO.AsyncAPI.Bindings; using LEGO.AsyncAPI.Bindings.Kafka; using LEGO.AsyncAPI.Models; - using LEGO.AsyncAPI.Models.Bindings.Kafka; using LEGO.AsyncAPI.Readers; using NUnit.Framework; - using System.Collections.Generic; internal class KafkaBindings_Should {