Code Monkey home page Code Monkey logo

writableoptions.net's People

Contributors

adamradocz avatar anpin avatar dependabot[bot] avatar hymccord avatar nogic1008 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

writableoptions.net's Issues

Support .NET 8

  • TargetFrameworks (#200)
  • Libraries (#200)
  • C# 12 New Features
  • devcontainer
  • GitHub Actions CI/CD (#200)
  • remove preview (after GA)

Settings file not found when updating

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!

Unable to reload in a Blazor Server App

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?

System.Text.Json.JsonReaderException:“'0xEF' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.”

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.