#nullable enable
namespace Svrnty.CQRS.Grpc;
///
/// Configuration options for gRPC CQRS endpoints
///
public class GrpcCqrsOptions
{
///
/// Gets whether reflection should be enabled
///
public bool ShouldEnableReflection { get; private set; }
private bool ShouldMapCommands { get; set; }
private bool ShouldMapQueries { get; set; }
private bool WasMappingMethodCalled { get; set; }
///
/// Enables gRPC reflection for the service
///
public GrpcCqrsOptions EnableReflection()
{
ShouldEnableReflection = true;
return this;
}
///
/// Maps command endpoints
///
public GrpcCqrsOptions MapCommands()
{
WasMappingMethodCalled = true;
ShouldMapCommands = true;
return this;
}
///
/// Maps query endpoints (includes dynamic queries)
///
public GrpcCqrsOptions MapQueries()
{
WasMappingMethodCalled = true;
ShouldMapQueries = true;
return this;
}
///
/// Maps both command and query endpoints
///
public GrpcCqrsOptions MapCommandsAndQueries()
{
WasMappingMethodCalled = true;
ShouldMapCommands = true;
ShouldMapQueries = true;
return this;
}
///
/// Gets whether commands should be mapped (defaults to true if no mapping methods were called)
///
public bool GetShouldMapCommands() => WasMappingMethodCalled ? ShouldMapCommands : true;
///
/// Gets whether queries should be mapped (defaults to true if no mapping methods were called)
///
public bool GetShouldMapQueries() => WasMappingMethodCalled ? ShouldMapQueries : true;
}