XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEExtension

【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFEExtension

更新md文档

9a6b514
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

2 个文件 +123 -2
Modified README.md +121 -2
@@ -18,6 +18,124 @@ XFEExtension库适用于各种C#项目,特别适合在需要提高代码可读
18 18
19 19 ---
20 20
21 ## 自动实现配置文件的存储
22
23 #### 基础用法
24
25 ```csharp
26 //创建配置文件类
27 static partial class SystemProfile
28 {
29 [ProfileProperty]
30 static string name;
31
32 [ProfileProperty]
33 static int _age;
34 }
35
36 //使用配置文件
37 class Program
38 {
39 static void Main(string[] args)
40 {
41 SystemProfile.Name = "Test";//在设置值的时候会自动记录并储存
42 //SystemProfile.Age = 1;
43 Console.WriteLine(SystemProfile.Name);
44 Console.WriteLine(SystemProfile.Age);//下次打开程序会自动读取上次程序退出时储存的值
45 }
46 }
47 ```
48
49 #### 设置get和set方法
50
51 ```csharp
52 static partial class SystemProfile
53 {
54 [ProfileProperty]
55 [ProfilePropertyAddGet(@"Console.WriteLine(""获取了Name"")")]
56 [ProfilePropertyAddGet("return name")]
57 [ProfilePropertyAddSet(@"Console.WriteLine(""设置了Name"")")]
58 [ProfilePropertyAddSet("name = value")]
59 private static string name = string.Empty;
60
61 [ProfileProperty]
62 [ProfilePropertyAddGet(@"Console.WriteLine(""获取了Age"")")]
63 [ProfilePropertyAddGet("return _age")]
64 [ProfilePropertyAddSet(@"Console.WriteLine(""设置了Age"")")]
65 [ProfilePropertyAddSet("_age = value")]
66 private static int _age;
67 }
68 ```
69
70 #### 设置初始值
71
72 ```csharp
73 static partial class SystemProfile
74 {
75 [ProfileProperty]
76 private static string name = "John Wick";
77
78 [ProfileProperty]
79 private static int _age = 59;
80 }
81 ```
82
83 #### 为属性添加注释
84
85 ```csharp
86 static partial class SystemProfile
87 {
88 /// <summary>
89 /// 名称
90 /// 这段注释会自动添加至自动生成的Name属性上
91 /// </summary>
92 [ProfileProperty]
93 private static string name;
94
95 [ProfileProperty]
96 private static int _age;
97 }
98 ```
99
100 ---
101
102 ## 使用LANDeviceDetector来检测本地局域网内的所有设备
103
104 #### 基础用法
105
106 ```csharp
107 var lANDeviceDetector = new LANDeviceDetector();
108 lANDeviceDetector.DeviceFind += (sender) =>
109 {
110 Console.WriteLine($"IP地址:{sender.IPAddress}\t设备名称:{sender.DeviceName}");
111 };
112 await lANDeviceDetector.StartDetecting();
113 ```
114
115 #### 自定义扫描频段
116
117 ```csharp
118 var lANDeviceDetector = new LANDeviceDetector("100.73.121.*");//这将扫描100.73.121.1到100.73.121.255的IP地址
119 lANDeviceDetector.DeviceFind += (sender) =>
120 {
121 Console.WriteLine($"IP地址:{sender.IPAddress}\t设备名称:{sender.DeviceName}");
122 };
123 await lANDeviceDetector.StartDetecting();
124 ```
125
126 #### 自定义超时
127
128 ```csharp
129 var lANDeviceDetector = new LANDeviceDetector("100.73.121.*", 2000);//这将会设置超时为2000ms
130 lANDeviceDetector.DeviceFind += (sender) =>
131 {
132 Console.WriteLine($"IP地址:{sender.IPAddress}\t设备名称:{sender.DeviceName}");
133 };
134 await lANDeviceDetector.StartDetecting();
135 ```
136
137 ---
138
21 139 ## XFE的ChatGPT使用示例
22 140
23 141 #### 最简单的用法
@@ -281,13 +399,14 @@ await group.StartXCC();//启动该群组的网络通讯
281 399
282 400 ---
283 401
284 ## 使用XFE下载器下载文件(支持继续上次下载等操作)
402 ## 使用XFE下载器来加速下载文件(支持继续上次下载、多线程加速下载等操作)
285 403
286 404 ```csharp
287 405 XFEDownloader xFEDownloader = new()
288 406 {
289 407 DownloadUrl = "https://www.nuget.org/api/v2/package/XFE%E5%90%84%E7%B1%BB%E6%8B%93%E5%B1%95.NetCore/1.2.2",
290 SavePath = "XFEExtension.NetCore.nuget"
408 SavePath = "XFEExtension.NetCore.nuget",
409 FileSegmentCount = 9 //设置9个线程来加速下载,建议数量不超过15个
291 410 };
292 411 xFEDownloader.BufferDownloaded += (sender, e) =>
293 412 {
Modified XFEExtension.NetCore.Analyzer.Test/SystemProfile.cs +2 -0
@@ -11,6 +11,8 @@ public static partial class SystemProfile
11 11 [ProfileProperty]
12 12 [ProfilePropertyAddGet(@"Console.WriteLine(""获取了Name"")")]
13 13 [ProfilePropertyAddGet("return name")]
14 [ProfilePropertyAddSet(@"Console.WriteLine(""设置了Name"")")]
15 [ProfilePropertyAddSet("name = value")]
14 16 private static string name = string.Empty;
15 17 #endregion
16 18 [ProfileProperty]