Adds Decorator, wip

This commit is contained in:
Janus C. H. Knudsen 2025-03-11 00:28:06 +01:00
parent a86a2d7ade
commit 49f9b99ee1
9 changed files with 112 additions and 45 deletions

View file

@ -1,4 +1,5 @@
using System.Data;
using System.Diagnostics;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
@ -6,19 +7,24 @@ namespace PlanTempus.Core.Database;
public class DatabaseScope : IDisposable
{
private readonly IOperationHolder<DependencyTelemetry> _operation;
internal readonly IOperationHolder<DependencyTelemetry> _operation;
private readonly Stopwatch _stopwatch;
public DatabaseScope(IDbConnection connection, IOperationHolder<DependencyTelemetry> operation)
{
Connection = connection;
_operation = operation;
_operation.Telemetry.Success = true;
_stopwatch = Stopwatch.StartNew();
}
public IDbConnection Connection { get; }
public void Dispose()
{
_stopwatch.Stop();
_operation.Telemetry.Duration = _stopwatch.Elapsed;
_operation.Dispose();
Connection.Dispose();
}

View file

@ -0,0 +1,14 @@
using Autofac;
using PlanTempus.Core.SeqLogging;
namespace PlanTempus.Core.ModuleRegistry
{
public class SecurityModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<SecureTokenizer>()
.As<ISecureTokenizer>();
}
}
}