Skip to content

Commit

Permalink
added UsageAware
Browse files Browse the repository at this point in the history
  • Loading branch information
meinsiedler committed Sep 24, 2018
1 parent 03fd04a commit c73fe34
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using softaware.UsageAware;
using System;
using System.Threading.Tasks;

namespace softaware.Cqs.Decorators.UsageAware
{
public class UsageAwareCommandLogger<TCommand> : UsageAwareLogger<TCommand>
where TCommand : ICommand
{
//// TODO
////public UsageAwareCommandLogger(IUsageAwareLogger logger)
//// : base(logger)
////{
////}
public UsageAwareCommandLogger(IUsageAwareLogger logger)
: base(logger)
{
}

public Task TimeAndLogCommandAsync(Func<Task> command)
{
Expand Down
16 changes: 8 additions & 8 deletions src/softaware.Cqs.Decorators.UsageAware/UsageAwareLogger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using softaware.UsageAware;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
Expand All @@ -17,7 +18,7 @@ protected enum LogType
private static readonly string Area;
private static readonly string Action;

//// TODO private readonly IUsageAwareLogger logger;
private readonly IUsageAwareLogger logger;

static UsageAwareLogger()
{
Expand All @@ -26,11 +27,10 @@ static UsageAwareLogger()
Action = type.Name;
}

//// TODO
////public UsageAwareLogger(IUsageAwareLogger logger)
////{
//// this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
////}
public UsageAwareLogger(IUsageAwareLogger logger)
{
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

protected async Task<Task> TimeAndLogAsync(Func<Task> commandOrQuery, LogType type)
{
Expand All @@ -45,7 +45,7 @@ protected async Task<Task> TimeAndLogAsync(Func<Task> commandOrQuery, LogType ty
{ "type", type.ToString() }
};

//// TODO await this.logger.TrackActionAsync(Area, Action, additionalProperties);
await this.logger.TrackActionAsync(Area, Action, additionalProperties);

return task;
}
Expand Down
12 changes: 6 additions & 6 deletions src/softaware.Cqs.Decorators.UsageAware/UsageAwareQueryLogger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using softaware.UsageAware;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -8,11 +9,10 @@ namespace softaware.Cqs.Decorators.UsageAware
public class UsageAwareQueryLogger<TQuery, TResult> : UsageAwareLogger<TQuery>
where TQuery : IQuery<TResult>
{
//// TODO
////public UsageAwareQueryLogger(IUsageAwareLogger logger)
//// : base(logger)
////{
////}
public UsageAwareQueryLogger(IUsageAwareLogger logger)
: base(logger)
{
}

public async Task<TResult> TimeAndLogQueryAsync(Func<Task<TResult>> query)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<Version>1.0.1</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="softaware.UsageAware" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\softaware.Cqs\softaware.Cqs.csproj" />
</ItemGroup>
Expand Down

0 comments on commit c73fe34

Please sign in to comment.