Skip to content

Commit

Permalink
允许从配置里面重新获取配置管理应用
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi committed Dec 10, 2024
1 parent 715c606 commit df4ba59
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/dotnetCampus.Configurations/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.CompilerServices;
using dotnetCampus.Configurations.Core;
Expand Down Expand Up @@ -271,5 +272,24 @@ protected void ClearValues()
/// 获取用于管理应用程序字符串配置项的管理器。
/// </summary>
internal IConfigurationRepo? Repo { get; set; }

internal IAppConfigurator? AppConfigurator { get; set; }

/// <summary>
/// 尝试获取 <see cref="IAppConfigurator"/> 实例。只有配置框架内部创建的配置,才能获取到 <see cref="IAppConfigurator"/> 实例。
/// </summary>
/// <param name="appConfigurator"></param>
/// <returns></returns>
public bool TryGetAppConfigurator
(
#if NETCOREAPP3_0_OR_GREATER
[NotNullWhen(true)]
#endif
out IAppConfigurator? appConfigurator
)
{
appConfigurator = AppConfigurator;
return appConfigurator != null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ private readonly ConcurrentDictionary<Type, Configuration> _configurationDiction
{
return new TConfiguration
{
Repo = _repo
Repo = _repo,
AppConfigurator = this,
};
});
}
Expand Down

0 comments on commit df4ba59

Please sign in to comment.