Goldev.Core
8.2.6
dotnet add package Goldev.Core --version 8.2.6
NuGet\Install-Package Goldev.Core -Version 8.2.6
<PackageReference Include="Goldev.Core" Version="8.2.6" />
<PackageVersion Include="Goldev.Core" Version="8.2.6" />
<PackageReference Include="Goldev.Core" />
paket add Goldev.Core --version 8.2.6
#r "nuget: Goldev.Core, 8.2.6"
#:package Goldev.Core@8.2.6
#addin nuget:?package=Goldev.Core&version=8.2.6
#tool nuget:?package=Goldev.Core&version=8.2.6
Goldev.Core
Пакет c общими элементами внутренних библиотек Goldev
Расширения для конфигурации
В пакете реализованы расширения для конфигурации приложения
конфигурация берётся по следующим приоритетам:
- Переменные окружения
- appsettings.json
- значение по умолчанию
Использование:
Создать Класс конфигурации
[AutoConfiguration] public class TestConfiguration { [FromEnvironment("TEST_CONFIG")] public string Test { get; init; } = string.Empty; // по умолчанию string.Empty }- Атрибут AutoConfiguration говорит, что мы не будем регистрировать IOptions вручную
- Атрибут FromEnvironment помечает свойство как свойство из переменных окружения, без него свойство будет браться только из appsetings.json
Зарегистрировать класс IOptions
- Если мы использовали атрибут AutoConfiguration
builder.Services.AddConfigurations(builder.Configuration); // Регистрируют все классы помеченные как AutoConfiguration - Если мы не использовали атрибут AutoConfiguration
builder.Services.ConfigureWithENV<TestConfiguration>(builder.Configuration) // Регистрирует класс TestConfiguration
- Если мы использовали атрибут AutoConfiguration
Добавить класс конфигурации в конструктор класса
public TestHandler(IOptions<TestConfiguration> options) { _config = options.Value }Добавить значения в appsettings.json или в переменные окружения
- appsettings.json
{ "TestConfiguration": "test" } - EnvironmentVariables
TEST_CONFIG = "test"
- appsettings.json
Константы
с версии 8.0.7 добавлена возможность прокидывать статические переменные из appsettings.json
Использование:
- В классе прописать анотации [TrackedType] для класса и [Constant] для статического поля
[TrackedType] public class TestClass { [Constant(BlockName = "Test", ConstantName = "Test1")] static int _test1; [Constant(BlockName = "Test", ConstantName = "Test2")] static TestEnum _testEnum; [Constant(BlockName = "Test")] static string _test3 { get; set; } = null!; [Constant(BlockName = "Test", ConstantName = "Test3")] static string _test5 = null!; [Constant(BlockName = "Test")] public static string Test4 = null!; [Constant(BlockName = "Test", ConstantName = "Test4")] public static string Test6 { get; set; } = null!; } - В appsettings.json прописать значения
{ "Test": { "Test1": 123, "Test2": 3, "Test3": "abacaba", "Test4": "hello world" } } - В program вызвать метод AddConstants();
builder.Configuration.AddConstants();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Goldev.Core:
| Package | Downloads |
|---|---|
|
Goldev.Core.Kafka
Package Description |
|
|
Goldev.Core.MediatR
Package Description |
|
|
Goldev.Cache.Redis
Package Description |
|
|
Goldev.Core.Logging
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 8.2.6 | 1,139 | 7/23/2026 | |
| 8.2.5 | 148 | 7/23/2026 | |
| 8.2.0 | 3,572 | 12/4/2024 | |
| 8.1.4 | 179 | 12/2/2024 | |
| 8.1.3 | 184 | 12/2/2024 | |
| 8.1.2 | 472 | 9/30/2024 | |
| 8.1.1 | 428 | 9/13/2024 | |
| 8.1.0 | 320 | 9/6/2024 | |
| 8.0.7 | 238 | 7/30/2024 | |
| 8.0.6 | 228 | 7/22/2024 | |
| 8.0.5 | 204 | 7/22/2024 | |
| 8.0.4 | 226 | 7/18/2024 | |
| 8.0.3 | 202 | 7/18/2024 | |
| 8.0.2 | 240 | 7/18/2024 | |
| 8.0.1 | 218 | 7/17/2024 |