From 129b497e5fa5c0ace59952ea2d94e3d7c98f2079 Mon Sep 17 00:00:00 2001 From: user135711 Date: Thu, 10 May 2018 21:43:20 -0700 Subject: [PATCH 1/2] Fix Np Completeness resolution and reference passing instead of primitive and strange variable assignment. --- .../sample/Extensions/ConfigurationMonitor.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/aspnetcore/fundamentals/primitives/change-tokens/sample/Extensions/ConfigurationMonitor.cs b/aspnetcore/fundamentals/primitives/change-tokens/sample/Extensions/ConfigurationMonitor.cs index a892852f5ec7..b7588a9e1529 100644 --- a/aspnetcore/fundamentals/primitives/change-tokens/sample/Extensions/ConfigurationMonitor.cs +++ b/aspnetcore/fundamentals/primitives/change-tokens/sample/Extensions/ConfigurationMonitor.cs @@ -26,10 +26,10 @@ public ConfigurationMonitor(IConfiguration config, IHostingEnvironment env) { _env = env; - ChangeToken.OnChange( + ChangeToken.OnChange( () => config.GetReloadToken(), - (state) => InvokeChanged(state), - "Not monitoring"); + InvokeChanged, + this); } public bool MonitoringEnabled { get; set; } = false; @@ -37,7 +37,7 @@ public ConfigurationMonitor(IConfiguration config, IHostingEnvironment env) #endregion #region snippet3 - private void InvokeChanged(string state) + private void InvokeChanged(IConfigurationMonitor state) { if (MonitoringEnabled) { @@ -48,13 +48,13 @@ private void InvokeChanged(string state) if (!_appsettingsHash.SequenceEqual(appsettingsHash) || !_appsettingsEnvHash.SequenceEqual(appsettingsEnvHash)) { - state = $"State updated at {DateTime.Now}"; - CurrentState = state; + string message = $"State updated at {DateTime.Now}"; + _appsettingsHash = appsettingsHash; _appsettingsEnvHash = appsettingsEnvHash; - WriteConsole($"Configuration changed (ConfigurationMonitor Class) {state}"); + WriteConsole($"Configuration changed (ConfigurationMonitor Class) {message}, state:{state.CurrentState}"); } } } From bb3fdeb663fe875956569ce388b921b61bbae6c3 Mon Sep 17 00:00:00 2001 From: user135711 Date: Thu, 10 May 2018 22:16:23 -0700 Subject: [PATCH 2/2] Make Cache in-memory compilable --- .../memory/sample/WebCache/WebCache.csproj | 11 +++++ .../memory/sample/WebCache/WebCache.xproj | 25 ----------- .../memory/sample/WebCache/project.json | 44 ------------------- 3 files changed, 11 insertions(+), 69 deletions(-) create mode 100644 aspnetcore/performance/caching/memory/sample/WebCache/WebCache.csproj delete mode 100644 aspnetcore/performance/caching/memory/sample/WebCache/WebCache.xproj delete mode 100644 aspnetcore/performance/caching/memory/sample/WebCache/project.json diff --git a/aspnetcore/performance/caching/memory/sample/WebCache/WebCache.csproj b/aspnetcore/performance/caching/memory/sample/WebCache/WebCache.csproj new file mode 100644 index 000000000000..16c7f93109d2 --- /dev/null +++ b/aspnetcore/performance/caching/memory/sample/WebCache/WebCache.csproj @@ -0,0 +1,11 @@ + + + + netcoreapp2.1 + + + + + + + diff --git a/aspnetcore/performance/caching/memory/sample/WebCache/WebCache.xproj b/aspnetcore/performance/caching/memory/sample/WebCache/WebCache.xproj deleted file mode 100644 index 12e6b1dc6e5e..000000000000 --- a/aspnetcore/performance/caching/memory/sample/WebCache/WebCache.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 6085fe17-7a61-45a5-88e5-8ada483f2457 - WebCache - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - - - - - diff --git a/aspnetcore/performance/caching/memory/sample/WebCache/project.json b/aspnetcore/performance/caching/memory/sample/WebCache/project.json deleted file mode 100644 index 52d02f12b16a..000000000000 --- a/aspnetcore/performance/caching/memory/sample/WebCache/project.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "dependencies": { - "Microsoft.AspNetCore.Mvc": "1.1.0", - "Microsoft.AspNetCore.Routing": "1.1.0", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", - "Microsoft.Extensions.Caching.Memory": "1.1.0", - "Microsoft.NETCore.App": { - "version": "1.1.0", - "type": "platform" - } - }, - - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final" - }, - - "frameworks": { - "netcoreapp1.1": { - } - }, - - "buildOptions": { - "emitEntryPoint": true, - "preserveCompilationContext": true - }, - - "runtimeOptions": { - "configProperties": { - "System.GC.Server": true - } - }, - - "publishOptions": { - "include": [ - "wwwroot", - "web.config" - ] - }, - - "scripts": { - "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] - } -}