From ce1315fbbecb8384e2fc992e4034aa86999ecf00 Mon Sep 17 00:00:00 2001 From: Zhiqiang Li Date: Wed, 18 May 2022 01:41:18 +0800 Subject: [PATCH 1/2] WithTopic extension method add overload (#864) WithTopic add enableRawPayload overload method Signed-off-by: stulzq Co-authored-by: Ryan Nowak Co-authored-by: halspang <70976921+halspang@users.noreply.github.com> --- .../DaprEndpointConventionBuilderExtensions.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Dapr.AspNetCore/DaprEndpointConventionBuilderExtensions.cs b/src/Dapr.AspNetCore/DaprEndpointConventionBuilderExtensions.cs index 79528bbbe..40b7e9669 100644 --- a/src/Dapr.AspNetCore/DaprEndpointConventionBuilderExtensions.cs +++ b/src/Dapr.AspNetCore/DaprEndpointConventionBuilderExtensions.cs @@ -31,6 +31,21 @@ public static class DaprEndpointConventionBuilderExtensions /// The builder object. public static T WithTopic(this T builder, string pubsubName, string name) where T : IEndpointConventionBuilder + { + return WithTopic(builder, pubsubName, name, false); + } + + /// + /// Adds metadata to the provided . + /// + /// The .\ + /// The name of the pubsub component to use. + /// The topic name. + /// The enable/disable raw pay load flag. + /// The type. + /// The builder object. + public static T WithTopic(this T builder, string pubsubName, string name, bool enableRawPayload) + where T : IEndpointConventionBuilder { if (builder is null) { @@ -40,7 +55,7 @@ public static T WithTopic(this T builder, string pubsubName, string name) ArgumentVerifier.ThrowIfNullOrEmpty(pubsubName, nameof(pubsubName)); ArgumentVerifier.ThrowIfNullOrEmpty(name, nameof(name)); - builder.WithMetadata(new TopicAttribute(pubsubName, name)); + builder.WithMetadata(new TopicAttribute(pubsubName, name, enableRawPayload)); return builder; } } From 26518321f25553ca34651b9335e7a5b4924e2df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=AC=E9=9B=A8=E5=A3=B0?= Date: Wed, 18 May 2022 01:44:53 +0800 Subject: [PATCH 2/2] Fix Adds DaprClient in Dapr.AspNetCore from AddSingleton to TryAddSingleton (#867) Signed-off-by: zhenlei520 --- src/Dapr.AspNetCore/DaprServiceCollectionExtensions.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Dapr.AspNetCore/DaprServiceCollectionExtensions.cs b/src/Dapr.AspNetCore/DaprServiceCollectionExtensions.cs index 5720b4931..1da42243d 100644 --- a/src/Dapr.AspNetCore/DaprServiceCollectionExtensions.cs +++ b/src/Dapr.AspNetCore/DaprServiceCollectionExtensions.cs @@ -16,6 +16,7 @@ namespace Microsoft.Extensions.DependencyInjection using System; using System.Linq; using Dapr.Client; + using Extensions; /// /// Provides extension methods for . @@ -44,7 +45,7 @@ public static void AddDaprClient(this IServiceCollection services, Action(); - services.AddSingleton(_ => + services.TryAddSingleton(_ => { var builder = new DaprClientBuilder(); if (configure != null)