返回提交历史
Added
AutoConfig.Test/AutoConfig.Test.csproj
+20
-0
Added
AutoConfig.Test/Program.cs
+11
-0
Added
AutoConfig.Test/SystemProfile.cs
+10
-0
Modified
XFEExtension.NetCore.AutoConfig.sln
+20
-10
Modified
XFEExtension.NetCore.AutoConfig/ProfileInfo.cs
+19
-1
Added
XFEExtension.NetCore.AutoConfig/ProfilePathAttribute.cs
+14
-0
Modified
XFEExtension.NetCore.AutoConfig/XFEExtension.NetCore.AutoConfig.csproj
+11
-4
Modified
XFEExtension.NetCore.AutoConfig/XFEProfile.cs
+2
-2
XFEstudio/XFEExtension.NetCore.AutoConfig
add-增加ProfilePath特性,可以为每一个配置文件类单独统一设置存储路径
c70cb17
代码差异
8 个文件
+107
-17
@@ -0,0 +1,20 @@
1
<Project Sdk="Microsoft.NET.Sdk">
2
3
<PropertyGroup>
4
<OutputType>Exe</OutputType>
5
<TargetFramework>net8.0</TargetFramework>
6
<ImplicitUsings>enable</ImplicitUsings>
7
<Nullable>enable</Nullable>
8
</PropertyGroup>
9
10
<ItemGroup>
11
<PackageReference Include="XFEExtension.NetCore" Version="3.0.0" />
12
<PackageReference Include="XFEExtension.NetCore.XUnit" Version="2.0.3" />
13
</ItemGroup>
14
15
<ItemGroup>
16
<ProjectReference Include="..\XFEExtension.NetCore.AutoConfig\XFEExtension.NetCore.AutoConfig.csproj" />
17
<ProjectReference Include="..\XFEExtension.NetCore.AutoConfig.Analyzer\XFEExtension.NetCore.AutoConfig.Analyzer.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
18
</ItemGroup>
19
20
</Project>
@@ -0,0 +1,11 @@
1
namespace AutoConfig.Test;
2
3
internal class Program
4
{
5
[SMTest]
6
public static void MainTest()
7
{
8
SystemProfile.MyNum = 2;
9
Console.WriteLine(SystemProfile.MyNum);
10
}
11
}
@@ -0,0 +1,10 @@
1
using XFEExtension.NetCore.AutoConfig;
2
3
namespace AutoConfig.Test;
4
5
[ProfilePath(@$"C:\Users\XFEstudio\Downloads\{nameof(SystemProfile)}.xfe")]
6
public partial class SystemProfile
7
{
8
[ProfileProperty]
9
private int myNum;
10
}
@@ -9,25 +9,35 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XFEExtension.NetCore.AutoCo
9
9
EndProject
10
10
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XFEExtension.NetCore.AutoConfig.Analyzer", "XFEExtension.NetCore.AutoConfig.Analyzer\XFEExtension.NetCore.AutoConfig.Analyzer.csproj", "{223198F6-C372-46F7-83E0-DC2504E7FDD3}"
11
11
EndProject
12
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoConfig.Test", "AutoConfig.Test\AutoConfig.Test.csproj", "{3F06E105-A7D9-42E4-8555-50760120B372}"
13
ProjectSection(ProjectDependencies) = postProject
14
{223198F6-C372-46F7-83E0-DC2504E7FDD3} = {223198F6-C372-46F7-83E0-DC2504E7FDD3}
15
{33769964-C49C-4997-BB87-F8DB9669C98E} = {33769964-C49C-4997-BB87-F8DB9669C98E}
16
EndProjectSection
17
EndProject
12
18
Global
13
GlobalSection(ExtensibilityGlobals) = postSolution
14
SolutionGuid = {C99AD407-FD04-4804-BD73-5FF02A85E71F}
19
GlobalSection(SolutionConfigurationPlatforms) = preSolution
20
Debug|Any CPU = Debug|Any CPU
21
Release|Any CPU = Release|Any CPU
15
22
EndGlobalSection
16
23
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
19
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
20
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Release|Any CPU.Build.0 = Release|Any CPU
21
24
{33769964-C49C-4997-BB87-F8DB9669C98E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22
25
{33769964-C49C-4997-BB87-F8DB9669C98E}.Debug|Any CPU.Build.0 = Debug|Any CPU
23
26
{33769964-C49C-4997-BB87-F8DB9669C98E}.Release|Any CPU.ActiveCfg = Release|Any CPU
24
27
{33769964-C49C-4997-BB87-F8DB9669C98E}.Release|Any CPU.Build.0 = Release|Any CPU
25
EndGlobalSection
26
GlobalSection(SolutionConfigurationPlatforms) = preSolution
27
Debug|Any CPU = Debug|Any CPU
28
Release|Any CPU = Release|Any CPU
28
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
30
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
31
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Release|Any CPU.Build.0 = Release|Any CPU
32
{3F06E105-A7D9-42E4-8555-50760120B372}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33
{3F06E105-A7D9-42E4-8555-50760120B372}.Debug|Any CPU.Build.0 = Debug|Any CPU
34
{3F06E105-A7D9-42E4-8555-50760120B372}.Release|Any CPU.ActiveCfg = Release|Any CPU
35
{3F06E105-A7D9-42E4-8555-50760120B372}.Release|Any CPU.Build.0 = Release|Any CPU
29
36
EndGlobalSection
30
37
GlobalSection(SolutionProperties) = preSolution
31
38
HideSolutionNode = FALSE
32
39
EndGlobalSection
40
GlobalSection(ExtensibilityGlobals) = postSolution
41
SolutionGuid = {C99AD407-FD04-4804-BD73-5FF02A85E71F}
42
EndGlobalSection
33
43
EndGlobal
@@ -36,7 +36,25 @@ public class ProfileInfo
36
36
public ProfileInfo(Type profileType, string path = "", string description = "")
37
37
{
38
38
Profile = profileType;
39
Path = path == "" ? $"{((XFEProfile.ProfilesRootPath[^1] == '/' || XFEProfile.ProfilesRootPath[^1] == '\\') ? $"{XFEProfile.ProfilesRootPath}{profileType.Name}.xfe" : $"{XFEProfile.ProfilesRootPath}/{profileType.Name}.xfe")}" : path;
39
var pathAttribute = profileType.GetCustomAttribute<ProfilePathAttribute>();
40
if (path == "")
41
{
42
if(pathAttribute is not null)
43
{
44
Path = pathAttribute.Path;
45
}
46
else
47
{
48
if (XFEProfile.ProfilesDefaultPath[^1] == '/' || XFEProfile.ProfilesDefaultPath[^1] == '\\')
49
Path = $"{XFEProfile.ProfilesDefaultPath}{profileType.Name}.xfe";
50
else
51
Path = $"{XFEProfile.ProfilesDefaultPath}/{profileType.Name}.xfe";
52
}
53
}
54
else
55
{
56
Path = path;
57
}
40
58
Description = description;
41
59
var profileEntryList = new List<ProfileEntryInfo>();
42
60
foreach (var memberInfo in profileType.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
@@ -0,0 +1,14 @@
1
namespace XFEExtension.NetCore.AutoConfig;
2
3
/// <summary>
4
/// 配置文件储存位置
5
/// </summary>
6
/// <param name="path">储存路径</param>
7
[AttributeUsage(AttributeTargets.Class)]
8
public class ProfilePathAttribute(string path) : Attribute
9
{
10
/// <summary>
11
/// 配置文件的存储路径
12
/// </summary>
13
public string Path { get; set; } = path;
14
}
@@ -15,12 +15,19 @@
15
15
<RepositoryUrl>https://github.com/XFEstudio/XFEExtension.NetCore.AutoConfig</RepositoryUrl>
16
16
<PackageProjectUrl>https://github.com/XFEstudio/XFEExtension.NetCore.AutoConfig</PackageProjectUrl>
17
17
<PackageTags>XFE;config;profile;auto</PackageTags>
18
<PackageReleaseNotes>更新命名空间和项目版本号
18
<PackageReleaseNotes>## 调整
19
19
20
在`ProfilePropertyAutoGenerator.cs`文件中,我们将所有的`global::XFEExtension.NetCore.ProfileExtension`命名空间更改为`global::XFEExtension.NetCore.AutoConfig`。这包括了`ProfileFieldAutoGenerateAttribute`,`XFEProfile.SaveProfile`,`XFEProfile`和`ProfileInstanceAttribute`的引用。此外,我们还在`XFEExtension.NetCore.AutoConfig.csproj`项目文件中,将版本号从`1.0.3`更新为`1.0.4`。
21
</PackageReleaseNotes>
20
无
21
22
## 新增
23
24
增加ProfilePath特性,可以为每一个配置文件类单独统一设置存储路径
25
26
## 严重
27
28
无</PackageReleaseNotes>
22
29
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
23
<Version>1.0.4</Version>
30
<Version>1.1.0</Version>
24
31
</PropertyGroup>
25
32
26
33
<ItemGroup>
@@ -34,9 +34,9 @@ public abstract class XFEProfile
34
34
public static List<ProfileInfo> Profiles { get; private set; } = [];
35
35
36
36
/// <summary>
37
/// 配置文件所在的根目录
37
/// 配置文件所在的默认目录
38
38
/// </summary>
39
public static string ProfilesRootPath { get; set; } = $"{AppDomain.CurrentDomain.BaseDirectory}/Profiles";
39
public static string ProfilesDefaultPath { get; set; } = $"{AppDomain.CurrentDomain.BaseDirectory}/Profiles";
40
40
41
41
/// <summary>
42
42
/// 加载配置文件