Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Configuration Extensions simplifies configuration

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to simplify the configuration of Configuration Extensions, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Before, I was like this.

Because the ip of the company ip is inconsistent with that of the home machine, you often need to switch configuration files.

But according to this configuration file, changing the host and port of the health check means I have to change three places, but in general, these three places are the same, if only I could define a variable "ServiceHost" at this time, and then use this variable in these three places.

Now, here's what I do.

If there are changes, you only need to change a few variable values, and you don't need to view and search for replacements in a full-screen configuration file.

Go back to the directory

Configuration sources supported by features

JSON

XML

Consul

Ini

Yaml

EnvironmentVariables

CommandLine

SQL Server/MySQL...

……

Writing so much is actually nonsense. It's just to list some common configuration sources.

Because this extension component is only rendered internally based on the "Microsoft.Extensions.Configuration" framework, it can be supported as long as it is adapted to the "Microsoft.Extensions.Configuration" configuration source.

Configuration information change re-rendering

When the configuration file changes and Reload is performed, the template will be automatically re-rendered, so you don't have to worry about the unavailability of configuration monitoring after rendering.

Go back to the directory

Demo

The configuration file is as follows:

The code is as follows:

Effect 1 (dotnet run):

Effect 2 (dotnet run-- ServiceHost=localhost):

Effect 3 (dotnet run-ServiceHost=localhost-ServicePort=5000):

Go back to the directory

Write at the end

The core of RabbitCloud is almost built, and an article will be written to explain it in the near future. Put some pictures first.

Thank you for reading this article carefully. I hope the article "how to simplify the configuration of Configuration Extensions" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report