-
Notifications
You must be signed in to change notification settings - Fork 24
/
TracingExtension.cs
32 lines (30 loc) · 1009 Bytes
/
TracingExtension.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
namespace Moryx.AbstractionLayer
{
/// <summary>
/// Extension to override tracing information
/// </summary>
public static class TracingExtension
{
/// <summary>
/// Transform tracing type on activity
/// </summary>
public static T TransformTracing<T>(this IActivity activity) where T : Tracing, new()
{
var baseType = (Activity) activity;
var tracing = baseType.Tracing.Transform<T>();
baseType.Tracing = tracing;
return tracing;
}
/// <summary>
/// Add a trace information to the tracing object
/// </summary>
/// <param name="activityTracing">Tracing to add information to</param>
/// <param name="setter">Setter delegate</param>
public static T Trace<T>(this T activityTracing, Action<T> setter) where T : Tracing, new()
{
setter(activityTracing);
return activityTracing;
}
}
}