We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
public class Startup { private ConfigurationReloadToken _changeToken = new ConfigurationReloadToken(); private byte[] _configFileHash = new byte[20]; public Startup(IConfiguration configuration) { Configuration = configuration; } public void ConfigureServices(IServiceCollection services) { ... } public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IConfiguration config) { ChangeToken.OnChange( () => config.GetReloadToken(), () => { byte[] configFileHash = ComputeHash("appSettings.json"); if (!_configFileHash.SequenceEqual(configFileHash)) { Log.Information("Configuration changed"); _configFileHash = configFileHash; } var previousToken = Interlocked.Exchange(ref _changeToken, new ConfigurationReloadToken()); previousToken.OnReload(); }); } private byte[] ComputeHash(string file) { if (File.Exists(file)) { using (var fs = File.OpenRead(file)) { return System.Security.Cryptography.SHA1.Create().ComputeHash(fs); } } else { return new byte[20]; } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: