Skip to content

Class GrpcRegistrationExtensions

Namespace: Momentum.ServiceDefaults.Api
Assembly: Momentum.ServiceDefaults.Api.dll

Provides extension methods for automatic gRPC service registration.

csharp
public static class GrpcRegistrationExtensions

Inheritance

objectGrpcRegistrationExtensions

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Methods

MapGrpcServices(IEndpointRouteBuilder)

Maps all gRPC services found in the entry assembly to endpoints.

csharp
public static void MapGrpcServices(this IEndpointRouteBuilder routeBuilder)

Parameters

routeBuilder IEndpointRouteBuilder

The endpoint route builder to register services with.

Remarks

This method uses reflection to discover all gRPC service implementations in the entry assembly and automatically registers them as endpoints. Services are identified by inheriting from a base class with the

.

MapGrpcServices(IEndpointRouteBuilder, Type)

Maps all gRPC services found in the specified type's assembly to endpoints.

csharp
public static void MapGrpcServices(this IEndpointRouteBuilder routeBuilder, Type assemblyMarker)

Parameters

routeBuilder IEndpointRouteBuilder

The endpoint route builder to register services with.

assemblyMarker Type

A type whose assembly will be scanned for gRPC services.

Remarks

This overload allows specifying a different assembly than the entry assembly by providing a marker type from the target assembly.