lawrence-laz / extensions.configuration.object Goto Github PK
View Code? Open in Web Editor NEWA simple way to do configuration using POCO objects.
License: MIT License
A simple way to do configuration using POCO objects.
License: MIT License
When IOptions
are loaded from Configuration
they can read enum
settings, but they need to be entered by name, rather than by value. Current implementation loads it as value, which results in all enum
values defaulting to first one.
C# Records have a compiler generated Type EqualityContract
property, once they get compiled into classes. When loading such a class, LoadRecursively fails with a StackOverflowException.
The property should not be loaded, I would say, but currently only fields are ignored when they have the CompilerGenerated
attribute. I propose to check properties in the same way, and I will make a PR with this implemented.
For reference, here is a new unit test case that fails in the current implementation:
public class RecordObjectTest
{
internal record MyConfiguration
{
public SubRecordConfiguration SubRecord;
public string MyKey;
}
internal record SubRecordConfiguration
{
public string Title;
public string Name;
public int Age;
}
[Fact]
public void AddObject_WithClassObject_ShouldLoadFieldsIntoConfiguration()
{
var configuration = new ConfigurationBuilder()
.AddObject(new MyConfiguration
{
SubRecord = new SubRecordConfiguration
{
Title = "Editor",
Name = "Joe Smith",
Age = 33
},
MyKey = "My appsettings.json Value",
})
.Build();
configuration["SubRecord:Title"].Should().Be("Editor");
configuration["SubRecord:Name"].Should().Be("Joe Smith");
configuration["SubRecord:Age"].Should().Be("33");
configuration["MyKey"].Should().Be("My appsettings.json Value");
}
}
Add tag in Extensions.Configuration.Object.csproj
.
<Authors>Laurynas Lazauskas</Authors>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.