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

XFEExtension.NetCore.AutoConfig

【DLL】自动实现配置文件的存储

公开
关注 0 Fork 0 Star 0
UTF-8
namespace XFEExtension.NetCore.AutoConfig.Tests;

[AutoLoadProfile(false)]
public partial class XfeRoundTripProfile : XFEProfile
{
    [ProfileProperty]
    private string value = "default";
}

[AutoLoadProfile(false)]
public partial class PartialPropertyProfile : XFEProfile
{
    [ProfileProperty]
    public static partial string Value { get; set; } = "partial-default";

    public PartialPropertyProfile() => DefaultProfileOperationMode = ProfileOperationMode.Xml;
}

[AutoLoadProfile(false)]
public partial class PartialPropertyDefaultProfile : XFEProfile
{
    [ProfileProperty]
    public static partial string Value { get; set; } = "partial-default";

    [ProfileProperty]
    public static partial List<string> Values { get; set; } = [];
}

[AutoLoadProfile(false)]
public partial class JsonRoundTripProfile : XFEProfile
{
    [ProfileProperty]
    private string value = "default";

    public JsonRoundTripProfile() => DefaultProfileOperationMode = ProfileOperationMode.Json;
}

[AutoLoadProfile(false)]
public partial class XmlRoundTripProfile : XFEProfile
{
    [ProfileProperty]
    private string value = "default";

    public XmlRoundTripProfile() => DefaultProfileOperationMode = ProfileOperationMode.Xml;
}

[AutoLoadProfile(false)]
[ProfilePath("custom/settings")]
public partial class AttributePathProfile : XFEProfile
{
    [ProfileProperty]
    private string value = "default";
}

[AutoLoadProfile(false)]
public partial class DefaultPathProfile : XFEProfile
{
    [ProfileProperty]
    private int value;
}

[AutoLoadProfile(false)]
public partial class FlushProfile : XFEProfile
{
    [ProfileProperty]
    private string value = "default";
}

[AutoLoadProfile(false)]
public partial class CorruptJsonProfile : XFEProfile
{
    [ProfileProperty]
    private string value = "default";

    public CorruptJsonProfile() => DefaultProfileOperationMode = ProfileOperationMode.Json;
}

[AutoLoadProfile(false)]
public partial class FailingSaveProfile : XFEProfile
{
    [ProfileProperty]
    private string value = "default";
}

[AutoLoadProfile(false)]
public partial class PathChangeProfile : XFEProfile
{
    [ProfileProperty]
    private int value;
}

public sealed class LargeSettingsDocument
{
    public string Name { get; set; } = string.Empty;

    public Dictionary<string, string> Metadata { get; set; } = [];

    public List<LargeSettingsItem> Items { get; set; } = [];
}

public sealed class LargeSettingsItem
{
    public int Id { get; set; }

    public string Name { get; set; } = string.Empty;

    public double[] Samples { get; set; } = [];
}

[AutoLoadProfile(false)]
public partial class LargeObjectProfile : XFEProfile
{
    [ProfileProperty("Data")]
    private LargeSettingsDocument data = new();

    public LargeObjectProfile() => DefaultProfileOperationMode = ProfileOperationMode.MessagePack;

    protected override int ProfileSchemaVersion => 1;

    protected override void ConfigureMigrations(ProfileMigrationBuilder migrations) => migrations.NoOp(0);
}

[AutoLoadProfile(false)]
public partial class UnversionedLargeObjectProfile : XFEProfile
{
    [ProfileProperty("Data")]
    private LargeSettingsDocument data = new();

    public UnversionedLargeObjectProfile() => DefaultProfileOperationMode = ProfileOperationMode.MessagePack;
}

[AutoLoadProfile(false)]
public partial class MigratingLargeObjectProfile : XFEProfile
{
    [ProfileProperty("CurrentData")]
    private LargeSettingsDocument currentData = new();

    public MigratingLargeObjectProfile() => DefaultProfileOperationMode = ProfileOperationMode.MessagePack;

    protected override int ProfileSchemaVersion => 1;

    protected override void ConfigureMigrations(ProfileMigrationBuilder migrations) => migrations
        .RenameProperty(0, "Data", "CurrentData");
}