返回提交历史
Modified
README.md
+22
-15
Added
README.zh-CN.md
+72
-0
XFEstudio/XFEExtension.NetCore.AutoPath
docs: add English README as main doc, move Chinese to README.zh-CN.md with badges
Agent-Logs-Url: https://github.com/XFEstudio/XFEExtension.NetCore.AutoPath/sessions/71e3a455-f555-47cf-95a8-cceb65aa035c Co-authored-by: XFEstudio <132526994+XFEstudio@users.noreply.github.com>
6cb0740
代码差异
2 个文件
+94
-15
@@ -1,44 +1,51 @@
1
1
# XFEExtension.NetCore.AutoPath
2
2
3
## 描述
3
[](https://www.nuget.org/packages/XFEExtension.NetCore.AutoPath/)
4
[](https://www.nuget.org/packages/XFEExtension.NetCore.AutoPath/)
5
[](LICENSE.txt)
6
[](https://dotnet.microsoft.com/)
4
7
5
自动路径创建工具,自动创建不存在的文件夹,对路径统一管理
8
[中文文档](README.zh-CN.md)
6
9
7
## 自动实现路径管理
10
## Description
8
11
9
#### 基础用法
12
An automatic path creation tool that automatically creates non-existent folders and provides unified path management.
13
14
## Auto Path Management
15
16
#### Basic Usage
10
17
11
18
```csharp
12
//创建路径管理类
19
// Create a path management class
13
20
public partial class AppPath
14
21
{
15
22
[AutoPath]
16
23
readonly static string myTestPath = "MyTestPath/Test";
17
24
[AutoPath]
18
readonly static string mySecTestPath = $"{MyTestPath}/Sec";//路径可以引用自动生成的路径
25
readonly static string mySecTestPath = $"{MyTestPath}/Sec"; // Paths can reference auto-generated paths
19
26
}
20
27
21
28
22
//使用统一管理的路径
29
// Use the unified path management
23
30
class Program
24
31
{
25
32
static void Main(string[] args)
26
33
{
27
File.WriteAllText($"{AppPath.MyTestPath}/test.txt", "Hello World");//此时如果没有MyTestPath则会自动创建
34
File.WriteAllText($"{AppPath.MyTestPath}/test.txt", "Hello World"); // MyTestPath will be auto-created if it does not exist
28
35
var exist = Directory.Exists(AppPath.MySecTestPath);
29
Console.WriteLine(exist);//结果为True
36
Console.WriteLine(exist); // Output: True
30
37
}
31
38
}
32
39
```
33
40
34
#### 为路径添加注释
41
#### Add Comments to Paths
35
42
36
43
```csharp
37
44
public partial class AppPath
38
45
{
39
46
/// <summary>
40
/// 测试路径
41
/// 这段注释会自动添加至自动生成的Name属性上
47
/// Test path
48
/// This comment will be automatically added to the auto-generated Name property
42
49
/// </summary>
43
50
[AutoPath]
44
51
readonly static string myTestPath = "MyTestPath/Test";
@@ -47,7 +54,7 @@ public partial class AppPath
47
54
}
48
55
```
49
56
50
#### 使用部分方法来设置get方法
57
#### Use Partial Methods to Set the Get Method
51
58
52
59
```csharp
53
60
public partial class AppPath
@@ -59,7 +66,7 @@ public partial class AppPath
59
66
60
67
static partial void GetMyTestPathProperty()
61
68
{
62
Console.WriteLine("获取了MyTestPath");
69
Console.WriteLine("MyTestPath was accessed");
63
70
}
64
71
}
65
```
72
```
@@ -0,0 +1,72 @@
1
# XFEExtension.NetCore.AutoPath
2
3
[](https://www.nuget.org/packages/XFEExtension.NetCore.AutoPath/)
4
[](https://www.nuget.org/packages/XFEExtension.NetCore.AutoPath/)
5
[](LICENSE.txt)
6
[](https://dotnet.microsoft.com/)
7
8
[English](README.md)
9
10
## 描述
11
12
自动路径创建工具,自动创建不存在的文件夹,对路径统一管理
13
14
## 自动实现路径管理
15
16
#### 基础用法
17
18
```csharp
19
//创建路径管理类
20
public partial class AppPath
21
{
22
[AutoPath]
23
readonly static string myTestPath = "MyTestPath/Test";
24
[AutoPath]
25
readonly static string mySecTestPath = $"{MyTestPath}/Sec";//路径可以引用自动生成的路径
26
}
27
28
29
//使用统一管理的路径
30
class Program
31
{
32
static void Main(string[] args)
33
{
34
File.WriteAllText($"{AppPath.MyTestPath}/test.txt", "Hello World");//此时如果没有MyTestPath则会自动创建
35
var exist = Directory.Exists(AppPath.MySecTestPath);
36
Console.WriteLine(exist);//结果为True
37
}
38
}
39
```
40
41
#### 为路径添加注释
42
43
```csharp
44
public partial class AppPath
45
{
46
/// <summary>
47
/// 测试路径
48
/// 这段注释会自动添加至自动生成的Name属性上
49
/// </summary>
50
[AutoPath]
51
readonly static string myTestPath = "MyTestPath/Test";
52
[AutoPath]
53
readonly static string mySecTestPath = $"{MyTestPath}/Sec";
54
}
55
```
56
57
#### 使用部分方法来设置get方法
58
59
```csharp
60
public partial class AppPath
61
{
62
[AutoPath]
63
readonly static string myTestPath = "MyTestPath/Test";
64
[AutoPath]
65
readonly static string mySecTestPath = $"{MyTestPath}/Sec";
66
67
static partial void GetMyTestPathProperty()
68
{
69
Console.WriteLine("获取了MyTestPath");
70
}
71
}
72
```