diff --git a/samples/feature/Core_9/Sample/CustomLogger.cs b/samples/feature/Core_9/Sample/CustomLogger.cs index a931b13d8e1..2b0517bfde4 100644 --- a/samples/feature/Core_9/Sample/CustomLogger.cs +++ b/samples/feature/Core_9/Sample/CustomLogger.cs @@ -18,7 +18,7 @@ public IDisposable StartTimer(string name) public void WriteSaga(IContainSagaData sagaData) { var serialized = JsonSerializer.Serialize(sagaData, options); - log.Warn($"Saga State: \r\n{serialized}"); + log.WarnFormat("Saga State: \n{0}", serialized); } class Log : @@ -35,7 +35,7 @@ public Log(string name) public void Dispose() { - log.Warn($"{name} took {stopwatch.ElapsedMilliseconds}ms to process"); + log.WarnFormat("{0} took {1}ms to process", name, stopwatch.ElapsedMilliseconds); } } } diff --git a/samples/feature/Core_9/Sample/Handler/Handler1.cs b/samples/feature/Core_9/Sample/Handler/Handler1.cs index 96c7e733305..5fc38db2340 100644 --- a/samples/feature/Core_9/Sample/Handler/Handler1.cs +++ b/samples/feature/Core_9/Sample/Handler/Handler1.cs @@ -12,7 +12,7 @@ public class Handler1 : public Task Handle(HandlerMessage message, IMessageHandlerContext context) { var milliseconds = random.Next(100, 1000); - log.Info($"HandlerMessage received going to Task.Delay({milliseconds}ms)"); + log.InfoFormat("HandlerMessage received going to Task.Delay({0}ms)", milliseconds); return Task.Delay(milliseconds, context.CancellationToken); } } diff --git a/samples/feature/Core_9/Sample/Handler/Handler2.cs b/samples/feature/Core_9/Sample/Handler/Handler2.cs index 4365c3107e3..06f4397c358 100644 --- a/samples/feature/Core_9/Sample/Handler/Handler2.cs +++ b/samples/feature/Core_9/Sample/Handler/Handler2.cs @@ -12,7 +12,7 @@ public class Handler2 : public Task Handle(HandlerMessage message, IMessageHandlerContext context) { var milliseconds = random.Next(100, 1000); - log.Info($"HandlerMessage received going to Task.Delay({milliseconds}ms)"); + log.InfoFormat("HandlerMessage received going to Task.Delay({0}ms)", milliseconds); return Task.Delay(milliseconds, context.CancellationToken); } } diff --git a/samples/feature/Core_9/Sample/Handler/HandlerTimerBehavior.cs b/samples/feature/Core_9/Sample/Handler/HandlerTimerBehavior.cs index f60d43e8973..8d31443407f 100644 --- a/samples/feature/Core_9/Sample/Handler/HandlerTimerBehavior.cs +++ b/samples/feature/Core_9/Sample/Handler/HandlerTimerBehavior.cs @@ -3,16 +3,9 @@ using NServiceBus.Pipeline; #region HandlerTimerBehavior -class HandlerTimerBehavior : +class HandlerTimerBehavior(CustomLogger logger) : Behavior { - CustomLogger logger; - - public HandlerTimerBehavior(CustomLogger logger) - { - this.logger = logger; - } - public override async Task Invoke(IInvokeHandlerContext context, Func next) { var handlerName = context.MessageHandler.Instance.GetType().Name; diff --git a/samples/feature/Core_9/Sample/Saga/SagaStateAuditBehavior.cs b/samples/feature/Core_9/Sample/Saga/SagaStateAuditBehavior.cs index 798b38ccc85..fee883efa7e 100644 --- a/samples/feature/Core_9/Sample/Saga/SagaStateAuditBehavior.cs +++ b/samples/feature/Core_9/Sample/Saga/SagaStateAuditBehavior.cs @@ -4,16 +4,9 @@ using NServiceBus.Sagas; #region SagaStateAuditBehavior -class SagaStateAuditBehavior : +class SagaStateAuditBehavior(CustomLogger logger) : Behavior { - CustomLogger logger; - - public SagaStateAuditBehavior(CustomLogger logger) - { - this.logger = logger; - } - public override async Task Invoke(IInvokeHandlerContext context, Func next) { await next(); diff --git a/samples/feature/sample.md b/samples/feature/sample.md index 6b4c2f23e90..d815986b42d 100644 --- a/samples/feature/sample.md +++ b/samples/feature/sample.md @@ -1,7 +1,7 @@ --- title: Building a custom feature summary: How to build a custom feature in NServiceBus -reviewed: 2022-06-01 +reviewed: 2024-12-19 component: Core related: - nservicebus/pipeline