diff --git a/src/Cosmos.I18N.Extensions.Autofac/Cosmos/AutofacRegisterExtensions.cs b/src/Cosmos.I18N.Extensions.Autofac/Cosmos/AutofacRegisterExtensions.cs
index f6468e7..276cd58 100644
--- a/src/Cosmos.I18N.Extensions.Autofac/Cosmos/AutofacRegisterExtensions.cs
+++ b/src/Cosmos.I18N.Extensions.Autofac/Cosmos/AutofacRegisterExtensions.cs
@@ -28,7 +28,7 @@ public static ContainerBuilder RegisterCosmosLocalization(this ContainerBuilder
optionAct?.Invoke(options);
var translationManager = new TranslationManager();
- var translationSetter = translationManager as ITranslationManSetter;
+ var translationSetter = (ITranslationManSetter) translationManager;
foreach (var package in options.TranslationPackages) {
var translationPackage = package.Value;
diff --git a/src/Cosmos.I18N.Extensions.Console/Cosmos.I18N.Extensions.Console.csproj b/src/Cosmos.I18N.Extensions.Console/Cosmos.I18N.Extensions.Console.csproj
index 5aa72e0..b886a56 100644
--- a/src/Cosmos.I18N.Extensions.Console/Cosmos.I18N.Extensions.Console.csproj
+++ b/src/Cosmos.I18N.Extensions.Console/Cosmos.I18N.Extensions.Console.csproj
@@ -20,10 +20,7 @@
-
+
diff --git a/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/ConsoleLanguageServiceProvider.cs b/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/ConsoleLanguageServiceProvider.cs
index 20f3a74..28944d7 100644
--- a/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/ConsoleLanguageServiceProvider.cs
+++ b/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/ConsoleLanguageServiceProvider.cs
@@ -11,7 +11,11 @@ public class ConsoleLanguageServiceProvider : ILanguageServiceProvider {
private readonly TranslationProcessor _translationProcessor;
- ///
+ ///
+ /// Create a new instance of .
+ ///
+ ///
+ ///
public ConsoleLanguageServiceProvider(ITranslationManager manager, TranslationProcessor processor) {
_translationManager = manager ?? throw new ArgumentNullException(nameof(manager));
_translationProcessor = processor ?? throw new ArgumentNullException(nameof(processor));
diff --git a/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/Core/I18NServiceCollection.cs b/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/Core/I18NServiceCollection.cs
index e79d04a..c11363a 100644
--- a/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/Core/I18NServiceCollection.cs
+++ b/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/Core/I18NServiceCollection.cs
@@ -24,7 +24,7 @@ public class I18NServiceCollection : II18NServiceCollection {
///
public I18NServiceCollection(IServiceCollection services = null, I18NOptions options = null) {
_services = services ?? new ServiceCollection();
- _options = options ?? new I18NOptions();
+ _options = I18NOptions.Create(options);
_translationManager = new TranslationManager();
AfterBuild(UpdateStaticResolver);
@@ -50,7 +50,11 @@ public II18NServiceCollection AddDependency(Action servicesA
return this;
}
- ///
+ ///
+ /// Build
+ ///
+ ///
+ ///
public IServiceProvider Build() {
if (_hasBuild) {
throw new InvalidOperationException("Only can be built once.");
diff --git a/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/GlobalConfigurationExtensions.cs b/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/GlobalConfigurationExtensions.cs
index 9e13706..c550ece 100644
--- a/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/GlobalConfigurationExtensions.cs
+++ b/src/Cosmos.I18N.Extensions.Console/Cosmos/I18N/Extensions/Console/GlobalConfigurationExtensions.cs
@@ -15,8 +15,10 @@ public static class GlobalConfigurationExtensions {
///
///
public static II18NServiceCollection ToGlobal(this II18NServiceCollection services, Action optionsAct) {
- if (services == null) throw new ArgumentNullException(nameof(services));
- if (optionsAct == null) throw new ArgumentNullException(nameof(optionsAct));
+ if (services is null)
+ throw new ArgumentNullException(nameof(services));
+ if (optionsAct is null)
+ throw new ArgumentNullException(nameof(optionsAct));
services.AppendOptionsAction(optionsAct);
diff --git a/src/Cosmos.I18N/Cosmos/I18N/Configurations/I18NOptions.cs b/src/Cosmos.I18N/Cosmos/I18N/Configurations/I18NOptions.cs
index e3331c2..122512a 100644
--- a/src/Cosmos.I18N/Cosmos/I18N/Configurations/I18NOptions.cs
+++ b/src/Cosmos.I18N/Cosmos/I18N/Configurations/I18NOptions.cs
@@ -60,8 +60,7 @@ public I18NOptions AddPackage(ITranslatePackage package, MergeLevel level = Merg
if (__translationPackages.TryGetValue(hashOfPackageKey, out var packageInstance)) {
var template = TranslatePackageMerger.Merge(packageInstance, package, level, customMergeProvider);
__translationPackages[hashOfPackageKey] = template;
- }
- else {
+ } else {
AddPackageInternal(package);
}
}
@@ -108,14 +107,12 @@ public I18NOptions AddResource(string packageKey, ITranslateResource resource) {
if (TryRegisterLanguageTagOnce(resource.Binding)) {
if (__translationPackages.TryGetValue(hashOfPackageKey, out var package)) {
package.AddResource(resource);
- }
- else {
+ } else {
var future = new TranslatePackage(packageKey, _fallbackExperimenter);
future.AddResource(resource);
AddPackageInternal(future);
}
- }
- else {
+ } else {
throw new InvalidOperationException($"Something broken when add new resource '{resource.Name}'.");
}
}
@@ -271,5 +268,24 @@ public I18NOptions RemoveLanguageTagChangedHandler() {
#endregion
+ ///
+ /// Create
+ ///
+ ///
+ ///
+ public static I18NOptions Create(Action optionAct = null) {
+ var options = new I18NOptions();
+ optionAct?.Invoke(options);
+ return options;
+ }
+
+ ///
+ /// Create
+ ///
+ ///
+ ///
+ public static I18NOptions Create(I18NOptions options) {
+ return options ?? new I18NOptions();
+ }
}
}
\ No newline at end of file