Skip to content

Commit

Permalink
Merge branch 'master' into publish-cloudevents
Browse files Browse the repository at this point in the history
  • Loading branch information
halspang committed May 20, 2022
2 parents ab981b4 + 2651832 commit d20159b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/Dapr.AspNetCore/DaprEndpointConventionBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ public static class DaprEndpointConventionBuilderExtensions
/// <returns>The <see cref="IEndpointConventionBuilder" /> builder object.</returns>
public static T WithTopic<T>(this T builder, string pubsubName, string name)
where T : IEndpointConventionBuilder
{
return WithTopic(builder, pubsubName, name, false);
}

/// <summary>
/// Adds <see cref="ITopicMetadata" /> metadata to the provided <see cref="IEndpointConventionBuilder" />.
/// </summary>
/// <param name="builder">The <see cref="IEndpointConventionBuilder" />.</param>\
/// <param name="pubsubName">The name of the pubsub component to use.</param>
/// <param name="name">The topic name.</param>
/// <param name="enableRawPayload">The enable/disable raw pay load flag.</param>
/// <typeparam name="T">The <see cref="IEndpointConventionBuilder" /> type.</typeparam>
/// <returns>The <see cref="IEndpointConventionBuilder" /> builder object.</returns>
public static T WithTopic<T>(this T builder, string pubsubName, string name, bool enableRawPayload)
where T : IEndpointConventionBuilder
{
if (builder is null)
{
Expand All @@ -40,7 +55,7 @@ public static T WithTopic<T>(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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Dapr.AspNetCore/DaprServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Microsoft.Extensions.DependencyInjection
using System;
using System.Linq;
using Dapr.Client;
using Extensions;

/// <summary>
/// Provides extension methods for <see cref="IServiceCollection" />.
Expand Down Expand Up @@ -44,7 +45,7 @@ public static void AddDaprClient(this IServiceCollection services, Action<DaprCl

services.AddSingleton<DaprClientMarkerService>();

services.AddSingleton(_ =>
services.TryAddSingleton(_ =>
{
var builder = new DaprClientBuilder();
if (configure != null)
Expand Down

0 comments on commit d20159b

Please sign in to comment.