{"path":"NexusReader.Web/Services/NativeStorageService.cs","purpose":"Provides a server-side Blazor implementation of INativeStorageService that reads/writes browser localStorage via IJSRuntime, with protections for prerendering/JS-unavailable scenarios and Result-based error handling.","classification":{"role":"service","layer":"infrastructure","confidence":0.8,"evidence":["Service naming pattern","Application/service path heuristic","Implements INativeStorageService (line 12)","Uses IJSRuntime to access localStorage via JS Interop (lines 14, 25, 38, 53, 67)","Summary comment states Server-side implementation handling JS Interop / prerendering (lines 7-11)"]},"className":"NativeStorageService","methods":[{"name":"NativeStorageService","line":16,"endLine":19,"signature":"(IJSRuntime jsRuntime) -> NativeStorageService","purpose":"Constructs the service and stores the IJSRuntime for JS interop calls.","calls":[],"actions":[{"id":"assignment_18","kind":"mapping","label":"Store IJS runtime","line":18,"detail":"_jsRuntime = jsRuntime","visibility":"detail-only","confidence":0.7}]},{"name":"SaveStringAsync","line":21,"endLine":32,"signature":"(string key, string value) -> Task","purpose":"Saves a string value into browser localStorage via JS interop; returns a FluentResults Result indicating success or failure.","calls":[],"actions":[{"id":"savestringasync_try_23_0","kind":"try","label":"Begins protected execution","line":23,"detail":"try","visibility":"primary-visible","confidence":0.84},{"id":"try-catch_23","kind":"mapping","label":"Return success or failure based on JS call","line":23,"detail":"try -> return Result.Ok(); catch(Exception ex) -> return Result.Fail(ex.Message)","visibility":"detail-only","confidence":0.7},{"id":"external-call_25","kind":"external-call","label":"Invoke JS to set localStorage item","line":25,"detail":"await _jsRuntime.InvokeVoidAsync(\"localStorage.setItem\", key, value)","visibility":"detail-only","confidence":0.7},{"id":"savestringasync_await_25_1","kind":"await","label":"Waits for async work","line":25,"detail":"await _jsRuntime.InvokeVoidAsync(\"localStorage.setItem\", key, value);","visibility":"secondary-visible","confidence":0.81},{"id":"return_26","kind":"return","label":"Result.Ok on success","line":26,"detail":"Result.Ok()","visibility":"detail-only","confidence":0.7},{"id":"savestringasync_return_26_2","kind":"return","label":"Returns result","line":26,"detail":"return Result.Ok();","visibility":"detail-only","confidence":0.7},{"id":"savestringasync_catch_28_3","kind":"catch","label":"Handles exception path","line":28,"detail":"catch (Exception ex)","conditionSummary":"Exception ex","outcomeLabels":["handled exception"],"visibility":"primary-visible","confidence":0.86},{"id":"return_30","kind":"return","label":"Result.Fail on exception","line":30,"detail":"Result.Fail(ex.Message)","visibility":"detail-only","confidence":0.7},{"id":"savestringasync_return_30_4","kind":"return","label":"Returns result","line":30,"detail":"return Result.Fail(ex.Message);","visibility":"detail-only","confidence":0.7}]},{"name":"GetStringAsync","line":34,"endLine":45,"signature":"(string key) -> Task>","purpose":"Reads a string value from browser localStorage via JS interop and wraps it in a FluentResults Result.","calls":[],"actions":[{"id":"getstringasync_try_36_0","kind":"try","label":"Begins protected execution","line":36,"detail":"try","visibility":"primary-visible","confidence":0.84},{"id":"try-catch_36","kind":"mapping","label":"Return value or failure based on JS call","line":36,"detail":"try -> return Result.Ok(value); catch(Exception ex) -> return Result.Fail(ex.Message)","visibility":"detail-only","confidence":0.7},{"id":"external-call_38","kind":"external-call","label":"Invoke JS to get localStorage item","line":38,"detail":"var value = await _jsRuntime.InvokeAsync(\"localStorage.getItem\", key)","visibility":"detail-only","confidence":0.7},{"id":"getstringasync_await_38_1","kind":"await","label":"Waits for async work","line":38,"detail":"var value = await _jsRuntime.InvokeAsync(\"localStorage.getItem\", key);","visibility":"secondary-visible","confidence":0.81},{"id":"return_39","kind":"return","label":"Result.Ok with returned string","line":39,"detail":"Result.Ok(value)","visibility":"detail-only","confidence":0.7},{"id":"getstringasync_return_39_2","kind":"return","label":"Returns result","line":39,"detail":"return Result.Ok(value);","visibility":"detail-only","confidence":0.7},{"id":"getstringasync_catch_41_3","kind":"catch","label":"Handles exception path","line":41,"detail":"catch (Exception ex)","conditionSummary":"Exception ex","outcomeLabels":["handled exception"],"visibility":"primary-visible","confidence":0.86},{"id":"return_43","kind":"return","label":"Result.Fail on exception","line":43,"detail":"Result.Fail(ex.Message)","visibility":"detail-only","confidence":0.7},{"id":"getstringasync_return_43_4","kind":"return","label":"Returns result","line":43,"detail":"return Result.Fail(ex.Message);","visibility":"detail-only","confidence":0.7}]},{"name":"SaveBoolAsync","line":47,"endLine":47,"signature":"(string key, bool value) -> Task","purpose":"Stores a boolean as a string in localStorage by delegating to SaveStringAsync.","calls":[{"targetFile":"self","targetMethod":"SaveStringAsync","callLine":47,"paramSummary":"key, value.ToString()"}],"actions":[{"id":"delegation_47","kind":"mapping","label":"Delegate to SaveStringAsync","line":47,"detail":"SaveStringAsync(key, value.ToString())","visibility":"detail-only","confidence":0.7}]},{"name":"GetBoolAsync","line":49,"endLine":61,"signature":"(string key, bool defaultValue = false) -> Task>","purpose":"Reads a boolean value from localStorage, with parsing, default fallback and exception-safe behavior.","calls":[],"actions":[{"id":"getboolasync_try_51_0","kind":"try","label":"Begins protected execution","line":51,"detail":"try","visibility":"primary-visible","confidence":0.84},{"id":"try-catch_51","kind":"mapping","label":"Catch any exception and return default","line":51,"detail":"catch -> return Result.Ok(defaultValue)","visibility":"detail-only","confidence":0.7},{"id":"external-call_53","kind":"external-call","label":"Invoke JS to get localStorage item","line":53,"detail":"var value = await _jsRuntime.InvokeAsync(\"localStorage.getItem\", key)","visibility":"detail-only","confidence":0.7},{"id":"getboolasync_await_53_1","kind":"await","label":"Waits for async work","line":53,"detail":"var value = await _jsRuntime.InvokeAsync(\"localStorage.getItem\", key);","visibility":"secondary-visible","confidence":0.81},{"id":"getboolasync_guard-clause_54_2","kind":"guard-clause","label":"Guards early exit or rejection path","line":54,"detail":"if (string.IsNullOrEmpty(value)) return Result.Ok(defaultValue);","conditionSummary":"string.IsNullOrEmpty(value)) return Result.Ok(defaultValue","outcomeLabels":["exit","continue"],"visibility":"primary-visible","confidence":0.9},{"id":"guard-clause_54","kind":"guard-clause","label":"Return default when stored value is null/empty","line":54,"detail":"if empty -> return Result.Ok(defaultValue)","conditionSummary":"string.IsNullOrEmpty(value)","outcomeLabels":["return default","continue"],"visibility":"detail-only","confidence":0.7},{"id":"return_55","kind":"return","label":"Result.Ok with boolean (parsed or default)","line":55,"detail":"Result.Ok(bool.TryParse(...) ? result : defaultValue)","visibility":"detail-only","confidence":0.7},{"id":"getboolasync_return_55_3","kind":"return","label":"Returns result","line":55,"detail":"return Result.Ok(bool.TryParse(value, out var result) ? result : defaultValue);","visibility":"detail-only","confidence":0.7},{"id":"parsing_55","kind":"mapping","label":"Try parse bool","line":55,"detail":"bool.TryParse(value, out var result) ? result : defaultValue","visibility":"detail-only","confidence":0.7},{"id":"getboolasync_catch_57_4","kind":"catch","label":"Handles exception path","line":57,"detail":"catch","outcomeLabels":["handled exception"],"visibility":"primary-visible","confidence":0.86},{"id":"getboolasync_return_59_5","kind":"return","label":"Returns result","line":59,"detail":"return Result.Ok(defaultValue);","visibility":"detail-only","confidence":0.7}]},{"name":"RemoveAsync","line":63,"endLine":74,"signature":"(string key) -> Task","purpose":"Removes an item from browser localStorage via JS interop and reports success/failure.","calls":[],"actions":[{"id":"removeasync_try_65_0","kind":"try","label":"Begins protected execution","line":65,"detail":"try","visibility":"primary-visible","confidence":0.84},{"id":"try-catch_65","kind":"mapping","label":"Return success or failure based on JS call","line":65,"detail":"try -> return Result.Ok(); catch(Exception ex) -> return Result.Fail(ex.Message)","visibility":"detail-only","confidence":0.7},{"id":"external-call_67","kind":"external-call","label":"Invoke JS to remove localStorage item","line":67,"detail":"await _jsRuntime.InvokeVoidAsync(\"localStorage.removeItem\", key)","visibility":"detail-only","confidence":0.7},{"id":"removeasync_await_67_1","kind":"await","label":"Waits for async work","line":67,"detail":"await _jsRuntime.InvokeVoidAsync(\"localStorage.removeItem\", key);","visibility":"secondary-visible","confidence":0.81},{"id":"return_68","kind":"return","label":"Result.Ok on success","line":68,"detail":"Result.Ok()","visibility":"detail-only","confidence":0.7},{"id":"removeasync_return_68_2","kind":"return","label":"Returns result","line":68,"detail":"return Result.Ok();","visibility":"detail-only","confidence":0.7},{"id":"removeasync_catch_70_3","kind":"catch","label":"Handles exception path","line":70,"detail":"catch (Exception ex)","conditionSummary":"Exception ex","outcomeLabels":["handled exception"],"visibility":"primary-visible","confidence":0.86},{"id":"return_72","kind":"return","label":"Result.Fail on exception","line":72,"detail":"Result.Fail(ex.Message)","visibility":"detail-only","confidence":0.7},{"id":"removeasync_return_72_4","kind":"return","label":"Returns result","line":72,"detail":"return Result.Fail(ex.Message);","visibility":"detail-only","confidence":0.7}]},{"name":"SaveSecureString","line":76,"endLine":76,"signature":"(string key, string value) -> Task","purpose":"Alias for SaveStringAsync; intended for secure-string semantics at the API level.","calls":[{"targetFile":"self","targetMethod":"SaveStringAsync","callLine":76,"paramSummary":"key, value"}],"actions":[{"id":"delegation_76","kind":"mapping","label":"Delegate to SaveStringAsync","line":76,"detail":"await SaveStringAsync(key, value)","visibility":"detail-only","confidence":0.7},{"id":"savesecurestring_await_76_0","kind":"await","label":"Waits for async work","line":76,"detail":"public async Task SaveSecureString(string key, string value) => await SaveStringAsync(key, value);","visibility":"secondary-visible","confidence":0.81}]},{"name":"GetSecureString","line":78,"endLine":78,"signature":"(string key) -> Task>","purpose":"Alias for GetStringAsync; intended for secure-string semantics at the API level.","calls":[{"targetFile":"self","targetMethod":"GetStringAsync","callLine":78,"paramSummary":"key"}],"actions":[{"id":"delegation_78","kind":"mapping","label":"Delegate to GetStringAsync","line":78,"detail":"await GetStringAsync(key)","visibility":"detail-only","confidence":0.7},{"id":"getsecurestring_await_78_0","kind":"await","label":"Waits for async work","line":78,"detail":"public async Task> GetSecureString(string key) => await GetStringAsync(key);","visibility":"secondary-visible","confidence":0.81}]},{"name":"RemoveSecureAsync","line":80,"endLine":80,"signature":"(string key) -> Task","purpose":"Alias for RemoveAsync; intended for secure-string removal semantics.","calls":[{"targetFile":"self","targetMethod":"RemoveAsync","callLine":80,"paramSummary":"key"}],"actions":[{"id":"delegation_80","kind":"mapping","label":"Delegate to RemoveAsync","line":80,"detail":"RemoveAsync(key)","visibility":"detail-only","confidence":0.7}]}],"types":[{"name":"NativeStorageService","kind":"model","line":12,"purpose":"Server-side implementation class that adapts INativeStorageService to IJSRuntime-based localStorage access.","fields":[{"name":"_jsRuntime","type":"IJSRuntime","required":true,"line":14,"description":"JS runtime used to invoke browser localStorage operations"}]}],"serviceRegistrations":[],"startupActions":[],"dependencies":["NexusReader.Application.Abstractions.Services (INativeStorageService)","Microsoft.JSInterop (IJSRuntime)","FluentResults (Result)"],"patterns":["Adapter","Facade"],"domainConcepts":["localStorage","JSInterop","secure storage","prerendering / JS-unavailable fallback"],"keyDetails":"Wraps IJSRuntime calls with try/catch and FluentResults; provides typed bool parsing with default fallbacks; offers secure-named aliases that delegate to base methods.","orchestrationMethods":[{"name":"SaveStringAsync","line":21,"confidence":0.57,"reason":"Contains 1 architectural actions relevant to business execution.","actionKinds":["try","mapping","external-call","await","return","catch"],"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"name":"GetStringAsync","line":34,"confidence":0.57,"reason":"Contains 1 architectural actions relevant to business execution.","actionKinds":["try","mapping","external-call","await","return","catch"],"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"name":"GetBoolAsync","line":49,"confidence":0.57,"reason":"Contains 1 architectural actions relevant to business execution.","actionKinds":["try","mapping","external-call","await","guard-clause","return","catch"],"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"name":"RemoveAsync","line":63,"confidence":0.57,"reason":"Contains 1 architectural actions relevant to business execution.","actionKinds":["try","mapping","external-call","await","return","catch"],"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]}],"typedContracts":[{"name":"NativeStorageService","kind":"model","line":12,"fieldCount":1,"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]}],"persistenceInteractions":[],"externalInteractions":[{"methodName":"SaveStringAsync","line":25,"kind":"external-call","detail":"await _jsRuntime.InvokeVoidAsync(\"localStorage.setItem\", key, value)","evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"methodName":"GetStringAsync","line":38,"kind":"external-call","detail":"var value = await _jsRuntime.InvokeAsync(\"localStorage.getItem\", key)","evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"methodName":"GetBoolAsync","line":53,"kind":"external-call","detail":"var value = await _jsRuntime.InvokeAsync(\"localStorage.getItem\", key)","evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"methodName":"RemoveAsync","line":67,"kind":"external-call","detail":"await _jsRuntime.InvokeVoidAsync(\"localStorage.removeItem\", key)","evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]}],"evidenceAnchors":[{"kind":"orchestration-method","label":"SaveStringAsync","line":21,"summary":"Contains 1 architectural actions relevant to business execution.","confidence":0.57,"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"kind":"orchestration-method","label":"GetStringAsync","line":34,"summary":"Contains 1 architectural actions relevant to business execution.","confidence":0.57,"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"kind":"orchestration-method","label":"GetBoolAsync","line":49,"summary":"Contains 1 architectural actions relevant to business execution.","confidence":0.57,"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"kind":"orchestration-method","label":"RemoveAsync","line":63,"summary":"Contains 1 architectural actions relevant to business execution.","confidence":0.57,"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"kind":"typed-contract","label":"NativeStorageService","line":12,"summary":"model with 1 fields.","confidence":0.8,"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"kind":"external-call","label":"SaveStringAsync","line":25,"summary":"await _jsRuntime.InvokeVoidAsync(\"localStorage.setItem\", key, value)","confidence":0.8,"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"kind":"external-call","label":"GetStringAsync","line":38,"summary":"var value = await _jsRuntime.InvokeAsync(\"localStorage.getItem\", key)","confidence":0.8,"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]},{"kind":"external-call","label":"GetBoolAsync","line":53,"summary":"var value = await _jsRuntime.InvokeAsync(\"localStorage.getItem\", key)","confidence":0.8,"evidencePaths":["NexusReader.Web/Services/NativeStorageService.cs"]}],"cacheMetadata":{"schemaVersion":2,"analysisVersion":"2026-05-23.cache-v1","contentChecksum":"a3639f6d680639316ceb775c25ed2170ac831732d92b9c52707cb9ba9cfb5e6f","sourceByteSize":2516,"analyzedAt":"2026-05-23T16:55:47.579Z","technology":"dotnet"}}