forked from neozhu/CleanArchitectureWithBlazorServer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
476 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 1 addition & 7 deletions
8
src/Application/Common/Extensions/SpecificationBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace CleanArchitecture.Blazor.Application.Common.Interfaces; | ||
|
||
public interface IUploadService | ||
{ | ||
Task<string> UploadAsync(UploadRequest request); | ||
void Remove(string filename); | ||
} |
5 changes: 3 additions & 2 deletions
5
src/Application/Common/Interfaces/Identity/IUsersStateContainer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
using System.Collections.Concurrent; | ||
using System.Collections.Concurrent; | ||
|
||
namespace CleanArchitecture.Blazor.Application.Common.Interfaces.Identity; | ||
|
||
public interface IUsersStateContainer | ||
{ | ||
ConcurrentDictionary<string, string> UsersByConnectionId { get; } | ||
event Action? OnChange; | ||
void AddOrUpdate(string connectionId, string? name); | ||
void AddOrUpdate(string connectionId, string? userId); | ||
void Remove(string connectionId); | ||
void Clear(string userId); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/Application/Features/AuditTrails/Specifications/AuditTrailAdvancedFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/Application/Features/Contacts/Commands/Create/CreateContactCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/Application/Features/Contacts/Commands/Update/UpdateContactCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
src/Application/Features/Contacts/Specifications/ContactAdvancedSpecification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
src/Application/Features/Documents/Specifications/AdvancedDocumentsFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
src/Application/Features/Documents/Specifications/AdvancedDocumentsSpecification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
src/Application/Features/Identity/Notifications/UpdateUserProfileCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
src/Application/Features/Products/Specifications/ProductAdvancedFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 39 additions & 3 deletions
42
src/Infrastructure/Services/Identity/UsersStateContainer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,63 @@ | ||
using System.Collections.Concurrent; | ||
using System.Collections.Concurrent; | ||
|
||
namespace CleanArchitecture.Blazor.Infrastructure.Services.Identity; | ||
|
||
|
||
/// <summary> | ||
/// Manages the state of users by their connection IDs. | ||
/// </summary> | ||
public class UsersStateContainer : IUsersStateContainer | ||
{ | ||
/// <summary> | ||
/// Gets the dictionary that maps connection IDs to user names. | ||
/// </summary> | ||
public ConcurrentDictionary<string, string> UsersByConnectionId { get; } = new(); | ||
|
||
/// <summary> | ||
/// Event triggered when the state changes. | ||
/// </summary> | ||
public event Action? OnChange; | ||
|
||
/// <summary> | ||
/// Adds or updates a user in the state container. | ||
/// </summary> | ||
/// <param name="connectionId">The connection ID of the user.</param> | ||
/// <param name="name">The name of the user.</param> | ||
public void AddOrUpdate(string connectionId, string? name) | ||
{ | ||
UsersByConnectionId.AddOrUpdate(connectionId, name ?? string.Empty, (key, oldValue) => name ?? string.Empty); | ||
NotifyStateChanged(); | ||
} | ||
|
||
/// <summary> | ||
/// Removes a user from the state container by their connection ID. | ||
/// </summary> | ||
/// <param name="connectionId">The connection ID of the user to remove.</param> | ||
public void Remove(string connectionId) | ||
{ | ||
UsersByConnectionId.TryRemove(connectionId, out var _); | ||
UsersByConnectionId.TryRemove(connectionId, out _); | ||
NotifyStateChanged(); | ||
} | ||
|
||
/// <summary> | ||
/// Clears all users with the specified name from the state container. | ||
/// </summary> | ||
/// <param name="userName">The name of the user to clear.</param> | ||
public void Clear(string userName) | ||
{ | ||
var keysToRemove = UsersByConnectionId.Where(kvp => kvp.Value == userName).Select(kvp => kvp.Key).ToList(); | ||
foreach (var key in keysToRemove) | ||
{ | ||
UsersByConnectionId.TryRemove(key, out _); | ||
} | ||
NotifyStateChanged(); | ||
} | ||
|
||
/// <summary> | ||
/// Notifies subscribers that the state has changed. | ||
/// </summary> | ||
private void NotifyStateChanged() | ||
{ | ||
OnChange?.Invoke(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.