This is a library of little tidbits we found useful around the QBE Lab. Mainly helps with JSON, loading settings, etc.
You can clone and add this project as a dependancy to yours, or install it as a package via Nuget:
Install-Package QBE.LabUtilities
Allows you to test to see if a function argument is null.
Enables the use of paths to properties in JsonProperty attributes:
class Person {
[JsonProperty("address.country")]
public string Country {get; set;}
}
var person = JsonConvert.DeserializeObject<Person>(
@"{
""address"": {
""country"": ""Norway""
}
}");
person.Country // => "Norway"Provides a generic logging class that provides a unified front for an arbitrary logging interface, allowing the user to switch loggers without changing a ton of code.
Represents a field or property that we can read/write.
Provides a generic way to load settings from JSON files and environment variables.
The JSON and environment settings are used according to the following semantics:
- Values present in the environment will overwrite those found in the settings file.
- If the JSON file does not exist, and message will be logged at the
LogLevel.Traceseverity, and the resulting object's properties are left as their default values. - Environment variables that start with the given prefix are converted from
SCREAMING_SNAKE_CASEtoUpperCamelCaseafter stripping the prefix to map them to corresponding fields.