Move files from ComputeSharp.SwapChain.Core to WinUI project

このコミットが含まれているのは:
Sergio Pedri committed 2023-10-11 00:19:55 +02:00
1 親 7f7e084974
コミット cb0977c0ea
17ファイル変更
+1 -52

検索条件に一致するファイルはありません

+51
ファイルの表示
@@ -0,0 +1,51 @@
using System;
using System.Diagnostics;
using System.Text;
#nullable enable
namespace ComputeSharp.SwapChain.Core.Services;
/// <summary>
/// A <see langword="class"/> that manages the analytics service in a test environment.
/// </summary>
public sealed class DebugAnalyticsService : IAnalyticsService
{
/// <inheritdoc/>
public void Log(string title, params (string Property, object? Value)[]? data)
{
StringBuilder builder = new();
_ = builder.AppendLine($"[EVENT]: \"{title}\"");
if (data is not null)
{
foreach ((string Property, object? Value) info in data)
{
_ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? "<NULL>"}\"");
}
}
Trace.Write(builder);
}
/// <inheritdoc/>
public void Log(Exception exception, params (string Property, object? Value)[]? data)
{
StringBuilder builder = new();
_ = builder.AppendLine($"[EXCEPTION]: \"{exception.GetType()}\"");
_ = builder.AppendLine(">> Stack trace");
_ = builder.AppendLine(exception.StackTrace);
if (data is not null)
{
foreach ((string Property, object? Value) info in data)
{
_ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? "<NULL>"}\"");
}
}
Trace.Write(builder);
}
}
+25
ファイルの表示
@@ -0,0 +1,25 @@
using System;
#nullable enable
namespace ComputeSharp.SwapChain.Core.Services;
/// <summary>
/// The default <see langword="interface"/> for an analytics service.
/// </summary>
public interface IAnalyticsService
{
/// <summary>
/// Logs an event with a specified title and optional properties.
/// </summary>
/// <param name="title">The title of the event to track.</param>
/// <param name="data">The optional event properties.</param>
void Log(string title, params (string Property, object? Value)[]? data);
/// <summary>
/// Logs an exception with optional properties.
/// </summary>
/// <param name="exception">The exception that has been thrown.</param>
/// <param name="data">The optional event properties.</param>
void Log(Exception exception, params (string Property, object? Value)[]? data);
}