mirror of
https://github.com/PacktPublishing/Web-Development-with-Blazor-Second-Edition.git
synced 2026-04-21 06:03:59 +00:00
Initial commit
This commit is contained in:
parent
2190113c56
commit
3088165398
1765 changed files with 192085 additions and 0 deletions
|
|
@ -0,0 +1,15 @@
|
|||
using Components.Interfaces;
|
||||
using Data.Models;
|
||||
|
||||
namespace BlazorServer.Services;
|
||||
|
||||
public class BlazorServerBlogNotificationService : IBlogNotificationService
|
||||
{
|
||||
public event Action<BlogPost>? BlogPostChanged;
|
||||
|
||||
public Task SendNotification(BlogPost post)
|
||||
{
|
||||
BlogPostChanged?.Invoke(post);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
namespace BlazorServer.Services;
|
||||
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
|
||||
using Components.Interfaces;
|
||||
|
||||
public class BlogProtectedBrowserStorage : IBrowserStorage
|
||||
{
|
||||
ProtectedSessionStorage Storage { get; set; }
|
||||
public BlogProtectedBrowserStorage(ProtectedSessionStorage storage)
|
||||
{
|
||||
Storage = storage;
|
||||
}
|
||||
public async Task DeleteAsync(string key)
|
||||
{
|
||||
await Storage.DeleteAsync(key);
|
||||
}
|
||||
public async Task<T?> GetAsync<T>(string key)
|
||||
{
|
||||
var value = await Storage.GetAsync<T>(key);
|
||||
if (value.Success)
|
||||
{
|
||||
return value.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
public async Task SetAsync(string key, object value)
|
||||
{
|
||||
await Storage.SetAsync(key, value);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue