nogic1008 / writableoptions.net Goto Github PK
View Code? Open in Web Editor NEWProvides Options<T> that can update values to source JSON file
License: MIT License
Provides Options<T> that can update values to source JSON file
License: MIT License
Allows developers to source step external NuGets
https://github.com/dotnet/sourcelink
I'll submit a PR shortly to resolve
If there is no appsettings.json then the application throws an error. Currently I get around it with the below:
private static void AddEnrollmentSettingsFile(HostBuilderContext hostContext, IServiceCollection services)
{
// Per https://github.com/nogic1008/WritableOptions.Net
var enrollmentSettingsPath = Path.Combine(AppConfigPath, EnrollmentSettingsFileName);
services.ConfigureWritable<EnrollmentSettings>(
hostContext.Configuration.GetSection(nameof(EnrollmentSettings)),
enrollmentSettingsPath);
if (File.Exists(enrollmentSettingsPath) == false)
File.AppendAllText(enrollmentSettingsPath, "{" + Environment.NewLine + "}");
}
Anything that would do this for me, without the above workaround?
Also is adding the settings file that will be modified via host builder ConfigureAppConfiguration((hostContext, config) => config.AddJsonFile(settingsPath))
needed?
Thanks for the great library, working great!
Hi,
I downloaded the nuget package but ran into some problems with missing dependencies.
So I try cloning this repo to test with a sandbox Blazor server app.
Everything works except that I noticed that when the parameter is set to "true", the reload does not happen because the IConfigurationRoot instance that is injected is always null (doesn't break, just doesn't reload).
Any suggestions?
I have created a project with the same functionality, plus a few more extra.
Should we merge the two?
The link: https://github.com/adamradocz/SharpUtilities/tree/main/SharpUtilities/Options
Fix or dismiss these warnings & annotations
System.Text.Json.JsonReaderException:“'0xEF' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.”
appsettings.json
{
"StartInfo": {
"Instances": 1,
"FileName": "",
"WinAppDriverFileName": "C:\\Program Files\\Windows Application Driver\\WinAppDriver.exe",
"GrpcAddress": "https://localhost:7001"
}
}
StartInfo in Program.cs
services.ConfigureWritable<StartInfo>(hostContext.Configuration.GetSection(StartInfo.ConfigurationSectionKey));
StartInfo.cs
public class StartInfo
{
/// <summary>
/// The key of the configuration section.
/// </summary>
public const string ConfigurationSectionKey = "StartInfo";
/// <summary>
/// Number of Instances , default 1
/// </summary>
public int? Instances { get; set; }
/// <summary>
///
/// </summary>
public string? WinAppDriverFileName { get; set; }
/// <summary>
///
/// </summary>
public string? FileName { get; set; }
/// <summary>
/// The specified address for Grpc channel
/// </summary>
public string? GrpcAddress { get; set; }
}
/// <summary>
/// StartInfo Options
/// </summary>
private readonly IWritableOptions<StartInfo> _options;
public WeChatWorker(
IWritableOptions<StartInfo> options
)
{
// StartInfo Options
_options = options ?? throw new ArgumentNullException(nameof(options));
}
var option = _options.Value ?? new StartInfo();
option.FileName = fileName;
_options.Update(option); // throw exception
The code above can not save option.
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.