dotnet 6和NetStandard 2.0中的配置manager的类似物和受保护的部分
在.NET框架中,我们曾经使用web.config或app.config使用configurationManager
或webconfigurationManager
读取配置段。
2个项目引人注目:
a)通过框架加载标准配置文件(XML)。因此,当您调用configurationManager
从中的任何 dll中的任何 dll中的任何 dll,您会获取通过应用程序域路由的部分或appsettings
。
b)有能力拥有受保护的部分,即您放置了一些开放的文本数据,并且在运行应用程序时,此数据将被加密。
现在,在.NET 6中,我们有很多关于 new 配置管理器的讨论 - microsoft.extensions.configuration.configurationmanager
。
首先,.NET Core没有它,但是Microsoft很快添加了system.configuration.configurationManager
,现在可用于net6.0
and netStandard2.0
我发现了如何使用microsoft.extensions.configuration.configurationmanager
直接从类库中找到零信息。这似乎都是为端点应用程序(执行程序集)设计的。
我似乎明白,如果您真的想要这样的东西,有多种方法,但所有方法似乎都过于令人费解,并且与ASP.NET Core直接相关。最后,不能解决主要问题 - 如何处理DLL的这些受保护的配置。例如,在我的体系结构中,EF的内容位于端点应用程序的2个级别。我不想在下面传递连接字符串。我希望我的EF层本身能够独立地找到加密连接,如果它是从控制台应用程序,测试项目或获胜表格中调用的。
在通常的情况下,所有这些事情是否有任何指导 - “我们现在在ASP.NET核心中拥有此类”?
In the .net framework, we've used to use either web.config or app.config with ConfigurationManager
or WebConfigurationManager
to read the configuration sections.
2 items stood out:
a) standard configuration file (XML) was loaded by framework. So when you call ConfigurationManager
from ANY DLL in your application assemblies you get the section or appSettings
that routed through Application Domain.
b) There was ability to have protected sections, i.e. you put some open text data and when application runs, this data will be encrypted.
Now, in .net 6 we have plenty of talk about new configuration manager -Microsoft.Extensions.Configuration.ConfigurationManager
.
At first .net core came without it but Microsoft soon added back System.Configuration.ConfigurationManager
, now available for net6.0
and netstandard2.0
I have found ZERO information on how to use Microsoft.Extensions.Configuration.ConfigurationManager
directly from a class library. It is all seem to be designed for endpoint application, the executing assembly.
I seem understand that if you really want something like this, there are ways of doing it but all of it seem to be overly convoluted and directly related to ASP.NET CORE. And in the end, does not solve the main issue - how to deal with these protected configs from a DLL. For example, in my architecture, the EF stuff is located 2 levels down from the endpoint app. I don't want to pass connection string down below. I want my EF layer to be able by itself find encrypted connection, independently, if it is invoked from a console app, test project or Win Forms.
Are there any guidance to all these things outside the usual - "we now have this class in asp.net core"??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我来了这个解决方案以实现此功能。它利用单例模式来实现这一目标。同样,这是一个原型。 3个项目
。不知道这是否是一个“好主意”
I came to this solution to achieve this functionality. It utilizes Singleton pattern to make this happen. And again, this is a prototype. 3 Projects
This works. Not sure if this is a "great idea"