mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-07-01 20:30:41 +00:00
refactor: Move the related configuration items to the Common library.
This commit is contained in:
parent
bccfaaaa5b
commit
9f96aa0186
@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZonyLrcTools.Tests", "tests
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZonyLrcTools.LocalServer", "src\ZonyLrcTools.LocalServer\ZonyLrcTools.LocalServer.csproj", "{2875A08A-FFD6-4863-B815-5384DCFE88FC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZonyLrcTools.Common", "src\ZonyLrcTools.Common\ZonyLrcTools.Common.csproj", "{9B42E4CA-61AA-4798-8D2B-2D8A7035EB67}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -31,6 +33,10 @@ Global
|
||||
{2875A08A-FFD6-4863-B815-5384DCFE88FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2875A08A-FFD6-4863-B815-5384DCFE88FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2875A08A-FFD6-4863-B815-5384DCFE88FC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9B42E4CA-61AA-4798-8D2B-2D8A7035EB67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9B42E4CA-61AA-4798-8D2B-2D8A7035EB67}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9B42E4CA-61AA-4798-8D2B-2D8A7035EB67}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9B42E4CA-61AA-4798-8D2B-2D8A7035EB67}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -42,5 +48,6 @@ Global
|
||||
{55D74323-ABFA-4A73-A3BF-F3E8D5DE6DE8} = {C29FB05C-54B1-4020-94D2-87E192EB2F98}
|
||||
{FFBD3200-568F-455B-8390-5E76C51D522C} = {AF8ADB2F-E46C-4DEE-8316-652D9FE1A69B}
|
||||
{2875A08A-FFD6-4863-B815-5384DCFE88FC} = {C29FB05C-54B1-4020-94D2-87E192EB2F98}
|
||||
{9B42E4CA-61AA-4798-8D2B-2D8A7035EB67} = {C29FB05C-54B1-4020-94D2-87E192EB2F98}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -1,16 +0,0 @@
|
||||
using ZonyLrcTools.Cli.Infrastructure.Tag;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Config;
|
||||
|
||||
public class ProviderOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 标签加载器相关的配置属性。
|
||||
/// </summary>
|
||||
public TagOption Tag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌词下载相关的配置信息。
|
||||
/// </summary>
|
||||
public LyricOption Lyric { get; set; }
|
||||
}
|
@ -3,6 +3,7 @@ using YamlDotNet.Serialization;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Lyric;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Network;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Tag;
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Config
|
||||
{
|
||||
@ -21,6 +22,6 @@ namespace ZonyLrcTools.Cli.Config
|
||||
/// <summary>
|
||||
/// 定义下载器的相关配置信息。
|
||||
/// </summary>
|
||||
public ProviderOption Provider { get; set; }
|
||||
public ProviderOptions Provider { get; set; }
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using ZonyLrcTools.Cli.Config;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Extensions;
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
{
|
||||
@ -17,11 +18,11 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
/// </summary>
|
||||
public bool IsPruneMusic => Count == 0;
|
||||
|
||||
public LyricConfigOption Option { get; private set; }
|
||||
public GlobalLyricsConfigOptions Options { get; private set; }
|
||||
|
||||
public LyricItemCollection(LyricConfigOption option)
|
||||
public LyricItemCollection(GlobalLyricsConfigOptions options)
|
||||
{
|
||||
Option = option;
|
||||
Options = options;
|
||||
}
|
||||
|
||||
public static LyricItemCollection operator +(LyricItemCollection left, LyricItemCollection right)
|
||||
@ -31,7 +32,7 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
return left;
|
||||
}
|
||||
|
||||
var option = left.Option;
|
||||
var option = left.Options;
|
||||
var newCollection = new LyricItemCollection(option);
|
||||
var indexDiff = left.Count - right.Count;
|
||||
if (!option.IsOneLine)
|
||||
@ -104,8 +105,8 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
public override string ToString()
|
||||
{
|
||||
var lyricBuilder = new StringBuilder();
|
||||
ForEach(lyric => lyricBuilder.Append(lyric).Append(Option.LineBreak));
|
||||
return lyricBuilder.ToString().TrimEnd(Option.LineBreak);
|
||||
ForEach(lyric => lyricBuilder.Append(lyric).Append(Options.LineBreak));
|
||||
return lyricBuilder.ToString().TrimEnd(Options.LineBreak);
|
||||
}
|
||||
|
||||
public byte[] GetUtf8Bytes()
|
||||
|
@ -1,25 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using YamlDotNet.Serialization;
|
||||
using ZonyLrcTools.Cli.Config;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Infrastructure.Tag
|
||||
{
|
||||
public class TagInfoProviderOption
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public int Priority { get; set; }
|
||||
|
||||
public Dictionary<string, string> Extensions { get; set; }
|
||||
}
|
||||
|
||||
public class TagOption
|
||||
{
|
||||
public IEnumerable<TagInfoProviderOption> Plugin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 屏蔽词功能相关配置。
|
||||
/// </summary>
|
||||
public BlockWordOption BlockWord { get; set; }
|
||||
}
|
||||
}
|
@ -43,4 +43,8 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZonyLrcTools.Common\ZonyLrcTools.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,9 +1,9 @@
|
||||
namespace ZonyLrcTools.Cli.Config
|
||||
namespace ZonyLrcTools.Common.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// 屏蔽词选项类。
|
||||
/// </summary>
|
||||
public class BlockWordOption
|
||||
public class BlockWordOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否启用本功能。
|
@ -1,22 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Lyric;
|
||||
using ZonyLrcTools.Common.Lyrics;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Config;
|
||||
namespace ZonyLrcTools.Common.Configuration;
|
||||
|
||||
public class LyricOption
|
||||
{
|
||||
public IEnumerable<LyricProviderOption> Plugin { get; set; }
|
||||
|
||||
public LyricConfigOption Config { get; set; }
|
||||
|
||||
public LyricProviderOption GetLyricProviderOption(string name)
|
||||
{
|
||||
return Plugin.FirstOrDefault(x => x.Name == name);
|
||||
}
|
||||
}
|
||||
|
||||
public class LyricConfigOption
|
||||
public class GlobalLyricsConfigOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 双语歌词是否合并为一行。
|
13
src/ZonyLrcTools.Common/Configuration/LyricsOptions.cs
Normal file
13
src/ZonyLrcTools.Common/Configuration/LyricsOptions.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace ZonyLrcTools.Common.Configuration;
|
||||
|
||||
public class LyricsOptions
|
||||
{
|
||||
public IEnumerable<LyricsProviderOptions> Plugin { get; set; }
|
||||
|
||||
public GlobalLyricsConfigOptions Config { get; set; }
|
||||
|
||||
public LyricsProviderOptions GetLyricProviderOption(string name)
|
||||
{
|
||||
return Plugin.FirstOrDefault(x => x.Name == name);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
namespace ZonyLrcTools.Cli.Config
|
||||
namespace ZonyLrcTools.Common.Configuration
|
||||
{
|
||||
public class LyricProviderOption
|
||||
public class LyricsProviderOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 歌词下载器的唯一标识。
|
14
src/ZonyLrcTools.Common/Configuration/ProviderOptions.cs
Normal file
14
src/ZonyLrcTools.Common/Configuration/ProviderOptions.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace ZonyLrcTools.Common.Configuration;
|
||||
|
||||
public class ProviderOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 标签加载器相关的配置属性。
|
||||
/// </summary>
|
||||
public TagInfoOptions Tag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌词下载相关的配置信息。
|
||||
/// </summary>
|
||||
public LyricsOptions Lyric { get; set; }
|
||||
}
|
11
src/ZonyLrcTools.Common/Configuration/TagInfoOptions.cs
Normal file
11
src/ZonyLrcTools.Common/Configuration/TagInfoOptions.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace ZonyLrcTools.Common.Configuration;
|
||||
|
||||
public class TagInfoOptions
|
||||
{
|
||||
public IEnumerable<TagInfoProviderOptions> Plugin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 屏蔽词功能相关配置。
|
||||
/// </summary>
|
||||
public BlockWordOptions BlockWord { get; set; }
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
namespace ZonyLrcTools.Common.Configuration
|
||||
{
|
||||
public class TagInfoProviderOptions
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public int Priority { get; set; }
|
||||
|
||||
public Dictionary<string, string> Extensions { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
namespace ZonyLrcTools.Common.Lyrics
|
||||
{
|
||||
/// <summary>
|
||||
/// 换行符格式定义。
|
9
src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj
Normal file
9
src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -2,6 +2,8 @@
|
||||
using Xunit;
|
||||
using ZonyLrcTools.Cli.Config;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Lyric;
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
using ZonyLrcTools.Common.Lyrics;
|
||||
|
||||
namespace ZonyLrcTools.Tests.Infrastructure.Lyric
|
||||
{
|
||||
@ -10,7 +12,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
|
||||
[Fact]
|
||||
public void LyricCollectionLineBreak_Test()
|
||||
{
|
||||
var lyricObject = new LyricItemCollection(new LyricConfigOption
|
||||
var lyricObject = new LyricItemCollection(new GlobalLyricsConfigOptions
|
||||
{
|
||||
IsOneLine = false,
|
||||
LineBreak = LineBreakType.MacOs
|
||||
|
Loading…
x
Reference in New Issue
Block a user