IPAddressService.DynamicAllocation.Assist
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package IPAddressService.DynamicAllocation.Assist --version 1.0.0
NuGet\Install-Package IPAddressService.DynamicAllocation.Assist -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IPAddressService.DynamicAllocation.Assist" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IPAddressService.DynamicAllocation.Assist --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: IPAddressService.DynamicAllocation.Assist, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install IPAddressService.DynamicAllocation.Assist as a Cake Addin #addin nuget:?package=IPAddressService.DynamicAllocation.Assist&version=1.0.0 // Install IPAddressService.DynamicAllocation.Assist as a Cake Tool #tool nuget:?package=IPAddressService.DynamicAllocation.Assist&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Startup.cs
services.AddHttpClient();
services.AddSingleton<DynamicAllocationHelp>();
var serviceProvider = services.BuildServiceProvider();
var result = serviceProvider.GetService<DynamicAllocationHelp>().UseHttpClientFactory().Result;
Console.WriteLine(result);
appsettings.json 或 环境变量设置
"GXT_ADDRESS": "http://39.105.81.29:5019/api/DynamicAllocation/GetConfig",
"GXT_APPKEY": "3ff8ca63a70e08414ce09c8ce911595a",
"GXT_SERVICENUMBER": "8ff200c9-15c1-4b45-84b6-5d9a40b7158c",
"GXT_COPYNUMBER": "72f040be-0f2c-11e9-95c4-00163e0ef044",
示例代码:
/// <summary>
/// 初始化动态配置文件
/// </summary>
/// <param name="services"></param>
private void InitDynamicAllocation(IServiceCollection services)
{
#if (!DEBUG)
SetDynamicAllocationProConfig( services);
#else
SetDynamicAllocationDevConfig( services);
#endif
}
/// <summary>
/// 开发环境
/// </summary>
private void SetDynamicAllocationDevConfig(IServiceCollection services)
{
string path = AppDomain.CurrentDomain.BaseDirectory + "appsettings.json";
string config = File.ReadAllText(path);
dynamic conf = JsonConvert.DeserializeObject<dynamic>(config);
DynamicAllocation.Add("MicroServiceAddress", conf.MicroServiceAddress);
DynamicAllocation.Add("ConnectionStrings", conf.DefaultConnection);
}
/// <summary>
/// 生产环境
/// </summary>
private void SetDynamicAllocationProConfig(IServiceCollection services)
{
services.AddHttpClient();
services.AddSingleton<DynamicAllocationHelp>();
var serviceProvider = services.BuildServiceProvider();
var result = serviceProvider.GetService<DynamicAllocationHelp>().UseHttpClientFactory().Result;
if (result == null) return;
foreach (var item in result)
{
DynamicAllocation.Add(item.code, JsonConvert.DeserializeObject<dynamic>(item.content));
}
}
/// <summary>
/// 存储动态配置文件信息
/// </summary>
public static Dictionary<string, dynamic> DynamicAllocation=new Dictionary<string, dynamic> ();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 2.1
- Microsoft.Extensions.Http (>= 2.1.1)
- Newtonsoft.Json (>= 11.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.