XFEExtension
【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
关注
0
Fork
0
Star
0
返回提交历史
Modified
XFEExtension.NetCore.Analyzer.Test/Program.cs
+2
-2
Modified
XFEExtension.NetCore.Analyzer.Test/SystemProfile.cs
+0
-11
Modified
XFEExtension.NetCore.Analyzer.Test/TestClass.cs
+1
-1
Added
XFEExtension.NetCore/XFETransform/EscapeConverter.cs
+46
-0
XFEstudio/XFEExtension
添加转义类
03a19a1
代码差异
4 个文件
+49
-14
@@ -16,8 +16,8 @@ internal class Program
16
16
var json = testClass.ToJson();
17
17
//var json = JsonSerializer.Serialize(testClass);
18
18
//testClass.Enum.ToString().CW();
19
Console.WriteLine(json);
20
JsonSerializer.Deserialize<TestClass>(json).X();
19
//Console.WriteLine(json);
20
//JsonSerializer.Deserialize<TestClass>(json).X();
21
21
}
22
22
}
23
23
enum MyEnum
@@ -4,17 +4,6 @@ namespace XFEExtension.NetCore.Analyzer.Test;
4
4
5
5
public static partial class SystemProfile
6
6
{
7
#region Name
8
/// <summary>
9
/// 名称
10
/// </summary>
11
[ProfileProperty]
12
[ProfilePropertyAddGet(@"Console.WriteLine(""获取了Name"")")]
13
[ProfilePropertyAddGet("return name")]
14
[ProfilePropertyAddSet(@"Console.WriteLine(""设置了Name"")")]
15
[ProfilePropertyAddSet("name = value")]
16
private static string name = string.Empty;
17
#endregion
18
7
[ProfileProperty]
19
8
private static int _age;
20
9
}
@@ -5,9 +5,9 @@ internal class TestClass(string name, string description, int age)
5
5
public int id;
6
6
private int data;
7
7
public string Name { get; set; } = name;
8
public List<List<string>> Tags { get; set; }
8
9
public bool MyProperty { get; set; }
9
10
public MyEnum Enum { get; set; }
10
11
public string Description { get; set; } = description;
11
12
public int Age { get; set; } = age;
12
public List<List<string>> Tags { get; set; }
13
13
}
@@ -0,0 +1,46 @@
1
namespace XFEExtension.NetCore.XFETransform;
2
3
/// <summary>
4
/// 转义器
5
/// </summary>
6
public class EscapeConverter(string escapeSymbol = "/", params string[] escapes)
7
{
8
/// <summary>
9
/// 转义用符号
10
/// </summary>
11
public string EscapeSymbol { get; set; } = escapeSymbol;
12
/// <summary>
13
/// 待转义的符号
14
/// </summary>
15
public string[] Escapes { get; set; } = escapes;
16
/// <summary>
17
/// 转义(生成转义后文本)
18
/// </summary>
19
/// <param name="str"></param>
20
/// <returns></returns>
21
public string Convert(string str)
22
{
23
str = ConvertEscapeSymbol(str);
24
foreach (string escape in Escapes)
25
{
26
str = str.Replace(escape, $"{EscapeSymbol}{escape}");
27
}
28
return str;
29
}
30
/// <summary>
31
/// 逆转义(生成原文)
32
/// </summary>
33
/// <param name="str"></param>
34
/// <returns></returns>
35
public string Inverse(string str)
36
{
37
foreach (string escape in Escapes)
38
{
39
str = str.Replace($"{EscapeSymbol}{escape}", escape);
40
}
41
str = InverseEscapeSymbol(str);
42
return str;
43
}
44
private string ConvertEscapeSymbol(string str) => str.Replace(EscapeSymbol, $"{EscapeSymbol}{EscapeSymbol}");
45
private string InverseEscapeSymbol(string str) => str.Replace($"{EscapeSymbol}{EscapeSymbol}", EscapeSymbol);
46
}