Skip to content

Commit f930abd

Browse files
committed
refactor: 重构代码
1 parent c5c3175 commit f930abd

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/BootstrapBlazor/Extensions/LocalizationOptionsExtensions.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,19 @@ public static IEnumerable<IConfigurationSection> GetJsonStringFromAssembly(this
2727
var builder = new ConfigurationBuilder();
2828

2929
// 获取程序集中的资源文件
30-
var assemblies = new HashSet<Assembly>() { assembly };
30+
var assemblies = new List<Assembly>() { assembly };
3131

32-
var entryAssembly = GetAssembly();
32+
// 获得主程序集资源文件
33+
// 支持合并操作
34+
var entryAssembly = GetEntryAssembly();
3335
if (assembly != entryAssembly)
3436
{
3537
assemblies.Add(entryAssembly);
3638
}
3739

3840
if (option.AdditionalJsonAssemblies != null)
3941
{
40-
foreach (var item in option.AdditionalJsonAssemblies)
41-
{
42-
assemblies.Add(item);
43-
}
42+
assemblies.AddRange(option.AdditionalJsonAssemblies);
4443
}
4544

4645
var streams = assemblies.SelectMany(i => option.GetResourceStream(i, cultureName)).ToList();
@@ -77,7 +76,7 @@ public static IEnumerable<IConfigurationSection> GetJsonStringFromAssembly(this
7776
return config.GetChildren();
7877

7978
[ExcludeFromCodeCoverage]
80-
Assembly GetAssembly() => Assembly.GetEntryAssembly() ?? assembly;
79+
Assembly GetEntryAssembly() => Assembly.GetEntryAssembly() ?? assembly;
8180
}
8281

8382
private static List<Stream> GetResourceStream(this JsonLocalizationOptions option, Assembly assembly, string cultureName)

0 commit comments

Comments
 (0)