diff --git a/src/Snap.Hutao/Snap.Hutao/Model/Intrinsic/Frozen/IntrinsicFrozen.cs b/src/Snap.Hutao/Snap.Hutao/Model/Intrinsic/Frozen/IntrinsicFrozen.cs
new file mode 100644
index 00000000..21a0946d
--- /dev/null
+++ b/src/Snap.Hutao/Snap.Hutao/Model/Intrinsic/Frozen/IntrinsicFrozen.cs
@@ -0,0 +1,63 @@
+// Copyright (c) DGP Studio. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Frozen;
+
+namespace Snap.Hutao.Model.Intrinsic.Frozen;
+
+///
+/// 本地化的不可变的原生枚举
+///
+[HighQuality]
+internal static class IntrinsicFrozen
+{
+ ///
+ /// 所属地区
+ ///
+ public static readonly FrozenSet AssociationTypes = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToFrozenSet();
+
+ ///
+ /// 武器类型
+ ///
+ public static readonly FrozenSet WeaponTypes = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToFrozenSet();
+
+ ///
+ /// 物品类型
+ ///
+ public static readonly FrozenSet ItemQualities = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToFrozenSet();
+
+ ///
+ /// 身材类型
+ ///
+ public static readonly FrozenSet BodyTypes = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToFrozenSet();
+
+ ///
+ /// 战斗属性
+ ///
+ public static readonly FrozenSet FightProperties = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToFrozenSet();
+
+ ///
+ /// 元素名称
+ ///
+ public static readonly FrozenSet ElementNames = FrozenSet.ToFrozenSet(
+ [
+ SH.ModelIntrinsicElementNameFire,
+ SH.ModelIntrinsicElementNameWater,
+ SH.ModelIntrinsicElementNameGrass,
+ SH.ModelIntrinsicElementNameElec,
+ SH.ModelIntrinsicElementNameWind,
+ SH.ModelIntrinsicElementNameIce,
+ SH.ModelIntrinsicElementNameRock,
+ ]);
+
+ public static readonly FrozenSet MaterialTypeDescriptions = FrozenSet.ToFrozenSet(
+ [
+ SH.ModelMetadataMaterialCharacterAndWeaponEnhancementMaterial,
+ SH.ModelMetadataMaterialCharacterEXPMaterial,
+ SH.ModelMetadataMaterialCharacterAscensionMaterial,
+ SH.ModelMetadataMaterialCharacterTalentMaterial,
+ SH.ModelMetadataMaterialCharacterLevelUpMaterial,
+ SH.ModelMetadataMaterialWeaponEnhancementMaterial,
+ SH.ModelMetadataMaterialWeaponAscensionMaterial,
+ ]);
+}
\ No newline at end of file
diff --git a/src/Snap.Hutao/Snap.Hutao/Model/Intrinsic/Immutable/IntrinsicImmutable.cs b/src/Snap.Hutao/Snap.Hutao/Model/Intrinsic/Immutable/IntrinsicImmutable.cs
deleted file mode 100644
index 30677afc..00000000
--- a/src/Snap.Hutao/Snap.Hutao/Model/Intrinsic/Immutable/IntrinsicImmutable.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) DGP Studio. All rights reserved.
-// Licensed under the MIT license.
-
-using System.Collections.Immutable;
-
-namespace Snap.Hutao.Model.Intrinsic.Immutable;
-
-///
-/// 本地化的不可变的原生枚举
-///
-[HighQuality]
-internal static class IntrinsicImmutable
-{
- ///
- /// 所属地区
- ///
- public static readonly ImmutableHashSet AssociationTypes = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToImmutableHashSet();
-
- ///
- /// 武器类型
- ///
- public static readonly ImmutableHashSet WeaponTypes = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToImmutableHashSet();
-
- ///
- /// 物品类型
- ///
- public static readonly ImmutableHashSet ItemQualities = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToImmutableHashSet();
-
- ///
- /// 身材类型
- ///
- public static readonly ImmutableHashSet BodyTypes = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToImmutableHashSet();
-
- ///
- /// 战斗属性
- ///
- public static readonly ImmutableHashSet FightProperties = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToImmutableHashSet();
-
- ///
- /// 元素名称
- ///
- public static readonly ImmutableHashSet ElementNames = new HashSet(7)
- {
- SH.ModelIntrinsicElementNameFire,
- SH.ModelIntrinsicElementNameWater,
- SH.ModelIntrinsicElementNameGrass,
- SH.ModelIntrinsicElementNameElec,
- SH.ModelIntrinsicElementNameWind,
- SH.ModelIntrinsicElementNameIce,
- SH.ModelIntrinsicElementNameRock,
- }.ToImmutableHashSet();
-
- public static readonly ImmutableHashSet MaterialTypeDescriptions = new HashSet(7)
- {
- SH.ModelMetadataMaterialCharacterAndWeaponEnhancementMaterial,
- SH.ModelMetadataMaterialCharacterEXPMaterial,
- SH.ModelMetadataMaterialCharacterAscensionMaterial,
- SH.ModelMetadataMaterialCharacterTalentMaterial,
- SH.ModelMetadataMaterialCharacterLevelUpMaterial,
- SH.ModelMetadataMaterialWeaponEnhancementMaterial,
- SH.ModelMetadataMaterialWeaponAscensionMaterial,
- }.ToImmutableHashSet();
-}
\ No newline at end of file
diff --git a/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Item/Material.cs b/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Item/Material.cs
index f818af7f..34e5908b 100644
--- a/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Item/Material.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Item/Material.cs
@@ -2,7 +2,7 @@
// Licensed under the MIT license.
using Snap.Hutao.Model.Intrinsic;
-using Snap.Hutao.Model.Intrinsic.Immutable;
+using Snap.Hutao.Model.Intrinsic.Frozen;
using Snap.Hutao.ViewModel.Cultivation;
using System.Text.RegularExpressions;
@@ -58,7 +58,7 @@ internal sealed class Material : DisplayItem
// Character Level-Up Material // 40体BOSS/周本掉落
// Weapon Enhancement Material // 魔矿
// Weapon Ascension Material // 武器本
- return IntrinsicImmutable.MaterialTypeDescriptions.Contains(TypeDescription);
+ return IntrinsicFrozen.MaterialTypeDescriptions.Contains(TypeDescription);
}
///
@@ -69,12 +69,13 @@ internal sealed class Material : DisplayItem
/// 是否为当日物品
public bool IsTodaysItem(bool treatSundayAsTrue = false)
{
- return DateTimeOffset.UtcNow.AddHours(4).DayOfWeek switch
+ // TODO: support different time zone
+ return (DateTimeOffset.Now - new TimeSpan(4, 0, 0)).DayOfWeek switch
{
DayOfWeek.Monday or DayOfWeek.Thursday => Materials.MondayThursdayItems.Contains(Id),
DayOfWeek.Tuesday or DayOfWeek.Friday => Materials.TuesdayFridayItems.Contains(Id),
DayOfWeek.Wednesday or DayOfWeek.Saturday => Materials.WednesdaySaturdayItems.Contains(Id),
- _ => false,
+ _ => treatSundayAsTrue,
};
}
diff --git a/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Item/Materials.cs b/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Item/Materials.cs
index 5c3725dd..e491d8d1 100644
--- a/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Item/Materials.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Item/Materials.cs
@@ -2,7 +2,7 @@
// Licensed under the MIT license.
using Snap.Hutao.Model.Primitive;
-using System.Collections.Immutable;
+using System.Collections.Frozen;
namespace Snap.Hutao.Model.Metadata.Item;
@@ -11,8 +11,8 @@ namespace Snap.Hutao.Model.Metadata.Item;
///
internal static class Materials
{
- private static readonly ImmutableHashSet MondayThursdayItemsInner = new HashSet
- {
+ public static FrozenSet MondayThursdayItems { get; } = FrozenSet.ToFrozenSet(
+ [
104301U, 104302U, 104303U, // 「自由」
104310U, 104311U, 104312U, // 「繁荣」
104320U, 104321U, 104322U, // 「浮世」
@@ -23,10 +23,10 @@ internal static class Materials
114025U, 114026U, 114027U, 114028U, // 远海夷地
114037U, 114038U, 114039U, 114040U, // 谧林涓露
114049U, 114050U, 114051U, 114052U, // 悠古弦音
- }.ToImmutableHashSet();
+ ]);
- private static readonly ImmutableHashSet TuesdayFridayItemsInner = new HashSet
- {
+ public static FrozenSet TuesdayFridayItems { get; } = FrozenSet.ToFrozenSet(
+ [
104304U, 104305U, 104306U, // 「抗争」
104313U, 104314U, 104315U, // 「勤劳」
104323U, 104324U, 104325U, // 「风雅」
@@ -37,10 +37,10 @@ internal static class Materials
114029U, 114030U, 114031U, 114032U, // 鸣神御灵
114041U, 114042U, 114043U, 114044U, // 绿洲花园
114053U, 114054U, 114055U, 114056U, // 纯圣露滴
- }.ToImmutableHashSet();
+ ]);
- private static readonly ImmutableHashSet WednesdaySaturdayItemsInner = new HashSet
- {
+ public static FrozenSet WednesdaySaturdayItems { get; } = FrozenSet.ToFrozenSet(
+ [
104307U, 104308U, 104309U, // 「诗文」
104316U, 104317U, 104318U, // 「黄金」
104326U, 104327U, 104328U, // 「天光」
@@ -51,20 +51,5 @@ internal static class Materials
114033U, 114034U, 114035U, 114036U, // 今昔剧画
114045U, 114046U, 114047U, 114048U, // 谧林涓露
114057U, 114058U, 114059U, 114060U, // 无垢之海
- }.ToImmutableHashSet();
-
- ///
- /// 周一/周四
- ///
- public static ImmutableHashSet MondayThursdayItems { get => MondayThursdayItemsInner; }
-
- ///
- /// 周二/周五
- ///
- public static ImmutableHashSet TuesdayFridayItems { get => TuesdayFridayItemsInner; }
-
- ///
- /// 周三/周六
- ///
- public static ImmutableHashSet WednesdaySaturdayItems { get => WednesdaySaturdayItemsInner; }
+ ]);
}
\ No newline at end of file
diff --git a/src/Snap.Hutao/Snap.Hutao/Package.appxmanifest b/src/Snap.Hutao/Snap.Hutao/Package.appxmanifest
index 4fc3eba6..9df9076c 100644
--- a/src/Snap.Hutao/Snap.Hutao/Package.appxmanifest
+++ b/src/Snap.Hutao/Snap.Hutao/Package.appxmanifest
@@ -12,7 +12,7 @@
+ Version="1.7.17.0" />
Snap Hutao
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Abstraction/DbStoreOptions.cs b/src/Snap.Hutao/Snap.Hutao/Service/Abstraction/DbStoreOptions.cs
index 85b95eb9..3ea09669 100644
--- a/src/Snap.Hutao/Snap.Hutao/Service/Abstraction/DbStoreOptions.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Service/Abstraction/DbStoreOptions.cs
@@ -29,6 +29,11 @@ internal abstract partial class DbStoreOptions : ObservableObject, IOptions默认值
/// 值
protected string GetOption(ref string? storage, string key, string defaultValue = "")
+ {
+ return GetOption(ref storage, key, () => defaultValue);
+ }
+
+ protected string GetOption(ref string? storage, string key, Func defaultValueFactory)
{
if (storage is not null)
{
@@ -38,7 +43,7 @@ internal abstract partial class DbStoreOptions : ObservableObject, IOptions();
- storage = appDbContext.Settings.SingleOrDefault(e => e.Key == key)?.Value ?? defaultValue;
+ storage = appDbContext.Settings.SingleOrDefault(e => e.Key == key)?.Value ?? defaultValueFactory();
}
return storage;
@@ -52,6 +57,11 @@ internal abstract partial class DbStoreOptions : ObservableObject, IOptions默认值
/// 值
protected bool GetOption(ref bool? storage, string key, bool defaultValue = false)
+ {
+ return GetOption(ref storage, key, () => defaultValue);
+ }
+
+ protected bool GetOption(ref bool? storage, string key, Func defaultValueFactory)
{
if (storage is not null)
{
@@ -62,7 +72,7 @@ internal abstract partial class DbStoreOptions : ObservableObject, IOptions();
string? value = appDbContext.Settings.SingleOrDefault(e => e.Key == key)?.Value;
- storage = value is null ? defaultValue : bool.Parse(value);
+ storage = value is null ? defaultValueFactory() : bool.Parse(value);
}
return storage.Value;
@@ -76,6 +86,11 @@ internal abstract partial class DbStoreOptions : ObservableObject, IOptions默认值
/// 值
protected int GetOption(ref int? storage, string key, int defaultValue = 0)
+ {
+ return GetOption(ref storage, key, () => defaultValue);
+ }
+
+ protected int GetOption(ref int? storage, string key, Func defaultValueFactory)
{
if (storage is not null)
{
@@ -86,7 +101,7 @@ internal abstract partial class DbStoreOptions : ObservableObject, IOptions();
string? value = appDbContext.Settings.SingleOrDefault(e => e.Key == key)?.Value;
- storage = value is null ? defaultValue : int.Parse(value, CultureInfo.InvariantCulture);
+ storage = value is null ? defaultValueFactory() : int.Parse(value, CultureInfo.InvariantCulture);
}
return storage.Value;
@@ -101,8 +116,8 @@ internal abstract partial class DbStoreOptions : ObservableObject, IOptions反序列化器
/// 默认值
/// 值
- protected T GetOption(ref T? storage, string key, Func deserializer, T defaultValue)
- where T : class
+ [return:NotNull]
+ protected T GetOption(ref T? storage, string key, Func deserializer, [DisallowNull] T defaultValue)
{
if (storage is not null)
{
@@ -113,37 +128,27 @@ internal abstract partial class DbStoreOptions : ObservableObject, IOptions();
string? value = appDbContext.Settings.SingleOrDefault(e => e.Key == key)?.Value;
- storage = value is null ? defaultValue : deserializer(value);
+ storage = value is null ? defaultValue : deserializer(value)!;
}
return storage;
}
- ///
- /// 从数据库中获取任何类型的数据
- ///
- /// 数据的类型
- /// 存储字段
- /// 键
- /// 反序列化器
- /// 默认值
- /// 值
- protected T GetOption(ref T? storage, string key, Func deserializer, T defaultValue)
- where T : struct
+ protected T GetOption(ref T? storage, string key, Func deserializer, Func defaultValueFactory)
{
if (storage is not null)
{
- return storage.Value;
+ return storage;
}
using (IServiceScope scope = serviceProvider.CreateScope())
{
AppDbContext appDbContext = scope.ServiceProvider.GetRequiredService();
string? value = appDbContext.Settings.SingleOrDefault(e => e.Key == key)?.Value;
- storage = value is null ? defaultValue : deserializer(value);
+ storage = value is null ? defaultValueFactory() : deserializer(value);
}
- return storage.Value;
+ return storage;
}
///
@@ -226,32 +231,6 @@ internal abstract partial class DbStoreOptions : ObservableObject, IOptions序列化器
/// 属性名称
protected void SetOption(ref T? storage, string key, T value, Func serializer, [CallerMemberName] string? propertyName = null)
- where T : class
- {
- if (!SetProperty(ref storage, value, propertyName))
- {
- return;
- }
-
- using (IServiceScope scope = serviceProvider.CreateScope())
- {
- AppDbContext appDbContext = scope.ServiceProvider.GetRequiredService();
- appDbContext.Settings.ExecuteDeleteWhere(e => e.Key == key);
- appDbContext.Settings.AddAndSave(new(key, serializer(value)));
- }
- }
-
- ///
- /// 将值存入数据库
- ///
- /// 数据的类型
- /// 存储字段
- /// 键
- /// 值
- /// 序列化器
- /// 属性名称
- protected void SetOption(ref T? storage, string key, T value, Func serializer, [CallerMemberName] string? propertyName = null)
- where T : struct
{
if (!SetProperty(ref storage, value, propertyName))
{
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/AppOptions.cs b/src/Snap.Hutao/Snap.Hutao/Service/AppOptions.cs
index 420da76e..4b0f32d8 100644
--- a/src/Snap.Hutao/Snap.Hutao/Service/AppOptions.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Service/AppOptions.cs
@@ -52,7 +52,7 @@ internal sealed partial class AppOptions : DbStoreOptions
///
public string PowerShellPath
{
- get => GetOption(ref powerShellPath, SettingEntry.PowerShellPath, GetPowerShellLocationOrEmpty());
+ get => GetOption(ref powerShellPath, SettingEntry.PowerShellPath, GetPowerShellLocationOrEmpty);
set => SetOption(ref powerShellPath, SettingEntry.PowerShellPath, value);
}
@@ -75,8 +75,8 @@ internal sealed partial class AppOptions : DbStoreOptions
///
public BackdropType BackdropType
{
- get => GetOption(ref backdropType, SettingEntry.SystemBackdropType, Enum.Parse, BackdropType.Mica);
- set => SetOption(ref backdropType, SettingEntry.SystemBackdropType, value, value => value.ToString());
+ get => GetOption(ref backdropType, SettingEntry.SystemBackdropType, v => Enum.Parse(v), BackdropType.Mica).Value;
+ set => SetOption(ref backdropType, SettingEntry.SystemBackdropType, value, value => value.ToString()!);
}
///
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/Factory/GachaConfigTypeComparer.cs b/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/Factory/GachaConfigTypeComparer.cs
index 66146618..c396f2ba 100644
--- a/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/Factory/GachaConfigTypeComparer.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/Factory/GachaConfigTypeComparer.cs
@@ -2,7 +2,7 @@
// Licensed under the MIT license.
using Snap.Hutao.Web.Hoyolab.Hk4e.Event.GachaInfo;
-using System.Collections.Immutable;
+using System.Collections.Frozen;
using System.Runtime.CompilerServices;
namespace Snap.Hutao.Service.GachaLog.Factory;
@@ -12,20 +12,20 @@ namespace Snap.Hutao.Service.GachaLog.Factory;
///
internal sealed class GachaConfigTypeComparer : IComparer
{
- private static readonly GachaConfigTypeComparer InnerShared = new();
- private static readonly ImmutableDictionary OrderMap = new Dictionary()
+ private static readonly Lazy LazyShared = new(() => new());
+ private static readonly FrozenDictionary OrderMap = new Dictionary()
{
[GachaConfigType.AvatarEventWish] = 0,
[GachaConfigType.AvatarEventWish2] = 1,
[GachaConfigType.WeaponEventWish] = 2,
[GachaConfigType.StandardWish] = 3,
[GachaConfigType.NoviceWish] = 4,
- }.ToImmutableDictionary();
+ }.ToFrozenDictionary();
///
/// 共享的比较器
///
- public static GachaConfigTypeComparer Shared { get => InnerShared; }
+ public static GachaConfigTypeComparer Shared { get => LazyShared.Value; }
///
public int Compare(GachaConfigType x, GachaConfigType y)
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Configuration/IgnoredInvalidChannelOptions.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Configuration/IgnoredInvalidChannelOptions.cs
index 4f1c8285..87ad8523 100644
--- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Configuration/IgnoredInvalidChannelOptions.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Configuration/IgnoredInvalidChannelOptions.cs
@@ -2,18 +2,18 @@
// Licensed under the MIT license.
using Snap.Hutao.Model.Intrinsic;
-using System.Collections.Immutable;
+using System.Collections.Frozen;
namespace Snap.Hutao.Service.Game.Configuration;
internal static class IgnoredInvalidChannelOptions
{
- private static readonly ImmutableHashSet InvalidOptions = new HashSet()
- {
- new(ChannelType.Bili, SubChannelType.Default, isOversea: true),
- new(ChannelType.Bili, SubChannelType.Official, isOversea: true),
- new(ChannelType.Official, SubChannelType.Google, isOversea: false),
- }.ToImmutableHashSet();
+ private static readonly FrozenSet InvalidOptions = FrozenSet.ToFrozenSet(
+ [
+ new ChannelOptions(ChannelType.Bili, SubChannelType.Default, isOversea: true),
+ new ChannelOptions(ChannelType.Bili, SubChannelType.Official, isOversea: true),
+ new ChannelOptions(ChannelType.Official, SubChannelType.Google, isOversea: false),
+ ]);
public static bool Contains(in ChannelOptions options)
{
diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/AvatarProperty.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/AvatarProperty.cs
index 477557f8..9154a949 100644
--- a/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/AvatarProperty.cs
+++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/AvatarProperty/AvatarProperty.cs
@@ -7,7 +7,6 @@ using Snap.Hutao.Control.Collection.Alternating;
using Snap.Hutao.Model;
using Snap.Hutao.Model.Intrinsic;
using System.Collections.Frozen;
-using System.Collections.Immutable;
namespace Snap.Hutao.ViewModel.AvatarProperty;
diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/AvatarFilter.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/AvatarFilter.cs
index abbe8ef6..5c6ac72b 100644
--- a/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/AvatarFilter.cs
+++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/AvatarFilter.cs
@@ -2,7 +2,7 @@
// Licensed under the MIT license.
using Microsoft.Extensions.Primitives;
-using Snap.Hutao.Model.Intrinsic.Immutable;
+using Snap.Hutao.Model.Intrinsic.Frozen;
using Snap.Hutao.Model.Metadata.Avatar;
namespace Snap.Hutao.ViewModel.Wiki;
@@ -35,31 +35,31 @@ internal static class AvatarFilter
continue;
}
- if (IntrinsicImmutable.ElementNames.Contains(value))
+ if (IntrinsicFrozen.ElementNames.Contains(value))
{
matches.Add(avatar.FetterInfo.VisionBefore == value);
continue;
}
- if (IntrinsicImmutable.AssociationTypes.Contains(value))
+ if (IntrinsicFrozen.AssociationTypes.Contains(value))
{
matches.Add(avatar.FetterInfo.Association.GetLocalizedDescriptionOrDefault() == value);
continue;
}
- if (IntrinsicImmutable.WeaponTypes.Contains(value))
+ if (IntrinsicFrozen.WeaponTypes.Contains(value))
{
matches.Add(avatar.Weapon.GetLocalizedDescriptionOrDefault() == value);
continue;
}
- if (IntrinsicImmutable.ItemQualities.Contains(value))
+ if (IntrinsicFrozen.ItemQualities.Contains(value))
{
matches.Add(avatar.Quality.GetLocalizedDescriptionOrDefault() == value);
continue;
}
- if (IntrinsicImmutable.BodyTypes.Contains(value))
+ if (IntrinsicFrozen.BodyTypes.Contains(value))
{
matches.Add(avatar.Body.GetLocalizedDescriptionOrDefault() == value);
continue;
diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WeaponFilter.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WeaponFilter.cs
index b07ffc46..0e1540f9 100644
--- a/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WeaponFilter.cs
+++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WeaponFilter.cs
@@ -2,7 +2,7 @@
// Licensed under the MIT license.
using Microsoft.Extensions.Primitives;
-using Snap.Hutao.Model.Intrinsic.Immutable;
+using Snap.Hutao.Model.Intrinsic.Frozen;
using Snap.Hutao.Model.Metadata.Weapon;
namespace Snap.Hutao.ViewModel.Wiki;
@@ -36,19 +36,19 @@ internal static class WeaponFilter
continue;
}
- if (IntrinsicImmutable.WeaponTypes.Contains(value))
+ if (IntrinsicFrozen.WeaponTypes.Contains(value))
{
matches.Add(weapon.WeaponType.GetLocalizedDescriptionOrDefault() == value);
continue;
}
- if (IntrinsicImmutable.ItemQualities.Contains(value))
+ if (IntrinsicFrozen.ItemQualities.Contains(value))
{
matches.Add(weapon.Quality.GetLocalizedDescriptionOrDefault() == value);
continue;
}
- if (IntrinsicImmutable.FightProperties.Contains(value))
+ if (IntrinsicFrozen.FightProperties.Contains(value))
{
matches.Add(weapon.GrowCurves.ElementAtOrDefault(1)?.Type.GetLocalizedDescriptionOrDefault() == value);
continue;
diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiAvatarViewModel.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiAvatarViewModel.cs
index 9804b221..cde3c7c4 100644
--- a/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiAvatarViewModel.cs
+++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiAvatarViewModel.cs
@@ -17,7 +17,6 @@ using Snap.Hutao.Service.Notification;
using Snap.Hutao.Service.User;
using Snap.Hutao.View.Dialog;
using Snap.Hutao.Web.Response;
-using System.Collections.Immutable;
using System.Runtime.InteropServices;
using CalculateAvatarPromotionDelta = Snap.Hutao.Web.Hoyolab.Takumi.Event.Calculate.AvatarPromotionDelta;
using CalculateClient = Snap.Hutao.Web.Hoyolab.Takumi.Event.Calculate.CalculateClient;
diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiMonsterViewModel.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiMonsterViewModel.cs
index b967965c..d65bde83 100644
--- a/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiMonsterViewModel.cs
+++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiMonsterViewModel.cs
@@ -7,7 +7,6 @@ using Snap.Hutao.Model.Metadata.Item;
using Snap.Hutao.Model.Metadata.Monster;
using Snap.Hutao.Model.Primitive;
using Snap.Hutao.Service.Metadata;
-using System.Collections.Immutable;
namespace Snap.Hutao.ViewModel.Wiki;
diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiWeaponViewModel.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiWeaponViewModel.cs
index fe709b05..9c096448 100644
--- a/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiWeaponViewModel.cs
+++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/Wiki/WikiWeaponViewModel.cs
@@ -17,7 +17,6 @@ using Snap.Hutao.Service.Notification;
using Snap.Hutao.Service.User;
using Snap.Hutao.View.Dialog;
using Snap.Hutao.Web.Response;
-using System.Collections.Immutable;
using System.Runtime.InteropServices;
using CalculateAvatarPromotionDelta = Snap.Hutao.Web.Hoyolab.Takumi.Event.Calculate.AvatarPromotionDelta;
using CalculateClient = Snap.Hutao.Web.Hoyolab.Takumi.Event.Calculate.CalculateClient;
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/HoyolabOptions.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/HoyolabOptions.cs
index 70bc2b45..f5e391a6 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/HoyolabOptions.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/HoyolabOptions.cs
@@ -3,7 +3,7 @@
using Microsoft.Extensions.Options;
using Snap.Hutao.Web.Hoyolab.DataSigning;
-using System.Collections.Immutable;
+using System.Collections.Frozen;
namespace Snap.Hutao.Web.Hoyolab;
@@ -32,7 +32,15 @@ internal sealed class HoyolabOptions : IOptions
///
public const string MobileUserAgentOversea = $"Mozilla/5.0 (Linux; Android 12) Mobile miHoYoBBSOversea/{SaltConstants.OSVersion}";
- private static readonly ImmutableDictionary SaltsInner = new Dictionary()
+ ///
+ /// 米游社设备Id
+ ///
+ public static string DeviceId { get; } = Guid.NewGuid().ToString();
+
+ ///
+ /// 盐
+ ///
+ public static FrozenDictionary Salts { get; } = new Dictionary()
{
// Chinese
[SaltType.K2] = SaltConstants.CNK2,
@@ -46,19 +54,7 @@ internal sealed class HoyolabOptions : IOptions
[SaltType.OSLK2] = SaltConstants.OSLK2,
[SaltType.OSX4] = "h4c1d6ywfq5bsbnbhm1bzq7bxzzv6srt",
[SaltType.OSX6] = "okr4obncj8bw5a65hbnn5oo6ixjc3l9w",
- }.ToImmutableDictionary();
-
- private static string? deviceId;
-
- ///
- /// 米游社设备Id
- ///
- public static string DeviceId { get => deviceId ??= Guid.NewGuid().ToString(); }
-
- ///
- /// 盐
- ///
- public static ImmutableDictionary Salts { get => SaltsInner; }
+ }.ToFrozenDictionary();
///
public HoyolabOptions Value { get => this; }