1
0

GUI 啟動完成

This commit is contained in:
2024-03-25 17:39:44 +08:00
parent 739e92cee8
commit 3382627c8c
18 changed files with 299 additions and 48 deletions

View File

@@ -0,0 +1,61 @@
using Newtonsoft.Json;
namespace CoreProfilerExample.Common.Options
{
public class CoreProfilerOption
{
/// <summary>
/// 資料保存上限(Session)。
/// </summary>
[JsonProperty("circularBufferSize")]
public int CircularBufferSize { get; set; } = 200;
/// <summary>
/// 要過濾掉的項目。
/// </summary>
[JsonProperty("filters")]
public IEnumerable<CoreProfilerOptionFilter> Filters { get; set; } = [
new CoreProfilerOptionFilter
{
Key = "/coreprofiler",
Value = "/coreprofiler",
Type = "CoreProfiler.ProfilingFilters.NameContainsProfilingFilter, CoreProfiler",
},
new CoreProfilerOptionFilter
{
Key = "static files",
Value = "ico,jpg,js,css,svg,json,ttf,woff,woff2,eot",
Type = "CoreProfiler.ProfilingFilters.FileExtensionProfilingFilter, CoreProfiler",
},
];
public CoreProfilerOption Save(string filename)
{
var json = JsonConvert.SerializeObject(this, Formatting.Indented);
File.WriteAllText(filename, json);
return this;
}
public static CoreProfilerOption UseCoreProfilerSetting()
{
var filename = Path.Combine(AppContext.BaseDirectory, "coreprofiler.json");
if (File.Exists(filename))
{
try
{
var json = File.ReadAllText(filename);
return JsonConvert.DeserializeObject<CoreProfilerOption>(json);
}
catch
{
}
}
return new CoreProfilerOption().Save(filename);
}
}
}

View File

@@ -0,0 +1,14 @@
using Newtonsoft.Json;
namespace CoreProfilerExample.Common.Options
{
public class CoreProfilerOptionFilter
{
[JsonProperty("key")]
public string Key { get; set; } = null!;
[JsonProperty("value")]
public string Value { get; set; } = null!;
[JsonProperty("type")]
public string Type { get; set; } = null!;
}
}