Skip to content
This repository was archived by the owner on Jan 25, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions App/CustomVarible.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json.Nodes;
using PCL.Core.IO;

namespace PCL.Core.App;

public class CustomVarible
{
/// <summary>
/// 自定义主页变量保存路径。
/// </summary>
public static string VaribleJsonPath { get; } = Path.Combine(FileService.SharedDataPath, "varibles.json");

/// <summary>
/// 存放所有自定义主页变量的 JSON 对象。
/// </summary>
public static JsonNode? VaribleJson;

public static Dictionary<string, string> VaribleDict = new();

public static void Set(string key, string value)
{

}

public static void Get(string key, string value)
{

}

public static void Init()
{
if (!File.Exists(VaribleJsonPath))
{
File.Create(VaribleJsonPath).Close();
}
else
{
try
{
VaribleJson = JsonNode.Parse(File.ReadAllText(VaribleJsonPath));
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
}
}
21 changes: 21 additions & 0 deletions Utils/Exts/StringExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;

namespace PCL.Core.Utils.Exts;
Expand Down Expand Up @@ -142,6 +143,26 @@ public string FromB32ToB10()
}
}

extension(string input)
{

public T ParseToEnum<T>() where T : struct, Enum
{
if (String.IsNullOrWhiteSpace(input))
{
return (T)(object)0;
}
else if (int.TryParse(input, out int numericValue))
{
return (T)(object)numericValue;
}
else
{
return Enum.Parse<T>(input, true);
}
}
}

extension([NotNullWhen(false)] string? value)
{
/// <summary>
Expand Down
Loading