I have a folder called Services; it is in fact in program.cs and a simple GET localStorage operation works fine. Now I am adding another function in the same file (Cache). This function needs to Set the data for a type (public class AppUserDto) that is in a class library called SharedDTOs, because it can be referred to from client (where Cache is) and also from API (backend server).
using Blazored.LocalStorage;
namespace client.Services
{
public class Cache
{
private readonly ILocalStorageService _localStorage;
public Cache(ILocalStorageService localStorage)
{
_localStorage = localStorage;
}
/// <summary>
/// User Specification
/// </summary>
public async Task<string> GetKnownAs()
{
return await _localStorage.GetItemAsStringAsync("knownAs") ?? string.Empty;
}
public async Task SetAppUser(AppUserDto dto)
{
await _localStorage.SetItemAsync<AppUserDto>("AppUser", dto);
}
}
}
The compiler can't find AppUserDto, which is like this:
using System;
namespace SharedDTOs {
public class AppUserDto {
public string Id { get; set; } = string.Empty;
public string UserName { get; set; } = string.Empty;
....
I tried adding a using SharedDTOs but that didn't work. ?