Beispiel #1
0
        static async Task InitBW(IServiceProvider services)
        {
            var js = services.GetRequiredService <IJSRuntime>();
            var ms = services.GetRequiredService <MemoryStorageService>();
            var ss = services.GetRequiredService <BrowserStorageService>();
            var sc = services.GetRequiredService <BrowserSecureStorageService>();

            _bw = new BWClient();
            _bw.CreateServiceResolver = (t, n) =>
            {
                if (t == typeof(ICryptoPrimitiveService))
                {
                    return(new JSInteropCryptoPrimitiveService(js));
                }
                if (t == typeof(IStorageService))
                {
                    if (n == "storageService")
                    {
                        return(ss);
                    }
                    else if (n == "secureStorageService")
                    {
                        //return ms;
                        return(sc);
                    }
                    else
                    {
                        throw new Exception("Unexpected storage service name: " + n);
                    }
                }
                return(null);
            };
            await _bw.InitAsync();
        }
Beispiel #2
0
 public AppState(BWClient bw)
 {
     _BW = bw;
 }