From 74992788082f90fe8327fa55cb30f25de2734d28 Mon Sep 17 00:00:00 2001 From: Ande Bell Date: Thu, 30 Nov 2023 14:17:55 -0700 Subject: [PATCH] adding/updating versioning --- .../JsModuleManager.cs | 9 ++++++-- .../Model/AuthenticationManager.cs | 22 ++++++------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/dymaptic.GeoBlazor.Core/JsModuleManager.cs b/src/dymaptic.GeoBlazor.Core/JsModuleManager.cs index 55f59bd4..34096214 100644 --- a/src/dymaptic.GeoBlazor.Core/JsModuleManager.cs +++ b/src/dymaptic.GeoBlazor.Core/JsModuleManager.cs @@ -1,4 +1,5 @@ using Microsoft.JSInterop; +using System.Security.Claims; namespace dymaptic.GeoBlazor.Core; @@ -6,11 +7,13 @@ internal static class JsModuleManager { public static async Task GetArcGisJsCore(IJSRuntime jsRuntime, IJSObjectReference? proModule, CancellationToken cancellationToken) { + var version = System.Reflection.Assembly.GetAssembly(typeof(JsModuleManager))!.GetName().Version; + if (proModule is null) { return await jsRuntime .InvokeAsync("import", cancellationToken, - "./_content/dymaptic.GeoBlazor.Core/js/arcGisJsInterop.js"); + $"./_content/dymaptic.GeoBlazor.Core/js/arcGisJsInterop.js?v={version}"); } return await proModule.InvokeAsync("getCore", cancellationToken); @@ -21,6 +24,8 @@ public static async Task GetArcGisJsCore(IJSRuntime jsRuntim /// public static async Task GetArcGisJsPro(IJSRuntime jsRuntime, CancellationToken cancellationToken) { + var version = System.Reflection.Assembly.GetAssembly(typeof(JsModuleManager))!.GetName().Version; + LicenseType licenseType = Licensing.GetLicenseType(); switch ((int)licenseType) @@ -28,7 +33,7 @@ public static async Task GetArcGisJsCore(IJSRuntime jsRuntim case >= 100: return await jsRuntime.InvokeAsync("import", cancellationToken, - "./_content/dymaptic.GeoBlazor.Pro/js/arcGisPro.js"); + $"./_content/dymaptic.GeoBlazor.Pro/js/arcGisPro.js?v={version}"); default: return null; } diff --git a/src/dymaptic.GeoBlazor.Core/Model/AuthenticationManager.cs b/src/dymaptic.GeoBlazor.Core/Model/AuthenticationManager.cs index 73811573..0067a641 100644 --- a/src/dymaptic.GeoBlazor.Core/Model/AuthenticationManager.cs +++ b/src/dymaptic.GeoBlazor.Core/Model/AuthenticationManager.cs @@ -1,4 +1,5 @@ using dymaptic.GeoBlazor.Core.Components.Views; +using dymaptic.GeoBlazor.Core.Objects; using Microsoft.Extensions.Configuration; using Microsoft.JSInterop; @@ -106,7 +107,7 @@ public async Task Initialize() _module = await arcGisJsInterop.InvokeAsync("getAuthenticationManager", _cancellationTokenSource.Token, DotNetObjectReference.Create(this), ApiKey, AppId, PortalUrl); } - + return true; } @@ -167,20 +168,11 @@ public async Task GetArcGisJsInterop() { LicenseType licenseType = Licensing.GetLicenseType(); - switch ((int)licenseType) - { - case >= 100: - // this is here to support the pro extension library - IJSObjectReference proModule = await _jsRuntime - .InvokeAsync("import", _cancellationTokenSource.Token, - "./_content/dymaptic.GeoBlazor.Pro/js/arcGisPro.js"); - - return await proModule.InvokeAsync("getCore"); - default: - return await _jsRuntime - .InvokeAsync("import", _cancellationTokenSource.Token, - "./_content/dymaptic.GeoBlazor.Core/js/arcGisJsInterop.js"); - } + var token = new CancellationToken(); + IJSObjectReference? arcGisPro = await JsModuleManager.GetArcGisJsPro(_jsRuntime, token); + IJSObjectReference arcGisJsInterop = await JsModuleManager.GetArcGisJsCore(_jsRuntime, arcGisPro, token); + + return arcGisJsInterop; } private readonly IJSRuntime _jsRuntime;