GUI 啟動完成
This commit is contained in:
61
CoreProfilerExample.Common/Options/CoreProfilerOption.cs
Normal file
61
CoreProfilerExample.Common/Options/CoreProfilerOption.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user