diff --git a/src/DotNext.MaintenanceServices/Maintenance/ApplicationMaintenanceInterfaceHost.cs b/src/DotNext.MaintenanceServices/Maintenance/ApplicationMaintenanceInterfaceHost.cs index 249200d79..ec05509eb 100644 --- a/src/DotNext.MaintenanceServices/Maintenance/ApplicationMaintenanceInterfaceHost.cs +++ b/src/DotNext.MaintenanceServices/Maintenance/ApplicationMaintenanceInterfaceHost.cs @@ -9,6 +9,7 @@ namespace DotNext.Maintenance; using Buffers; +using Collections.Specialized; using Security.Principal; using static IO.TextStreamExtensions; using static Runtime.InteropServices.UnixDomainSocketInterop; @@ -236,7 +237,7 @@ protected sealed override async Task ExecuteAsync(CancellationToken token) } } - private sealed class MaintenanceSession : Dictionary, IMaintenanceSession + private sealed class MaintenanceSession : TypeMap, IMaintenanceSession { private object? identityOrPrincipal; @@ -263,7 +264,7 @@ internal MaintenanceSession(Socket socket, Encoding encoding, BufferWriter public TextWriter ResponseWriter { get; } - IDictionary IMaintenanceSession.Context => this; + ITypeMap IMaintenanceSession.Context => this; private void Dispose(bool disposing) { diff --git a/src/DotNext.MaintenanceServices/Maintenance/CommandLine/Authentication/AuthenticationMiddleware.cs b/src/DotNext.MaintenanceServices/Maintenance/CommandLine/Authentication/AuthenticationMiddleware.cs index bab77e305..0fee943e9 100644 --- a/src/DotNext.MaintenanceServices/Maintenance/CommandLine/Authentication/AuthenticationMiddleware.cs +++ b/src/DotNext.MaintenanceServices/Maintenance/CommandLine/Authentication/AuthenticationMiddleware.cs @@ -13,7 +13,7 @@ internal static async Task AuthenticateAsync(this IAuthenticationHandler handler { var session = (context.Console as IMaintenanceConsole)?.Session; - if (session?.Principal is { Identity: { IsAuthenticated: true } }) + if (session?.Principal is { Identity.IsAuthenticated: true }) { // already authenticated await next(context).ConfigureAwait(false); @@ -33,7 +33,7 @@ internal static async Task AuthenticateAsync(this IAuthenticationHandler handler internal static Task SetDefaultPrincipal(InvocationContext context, Func next) { - if ((context.Console as IMaintenanceConsole)?.Session is { Principal: null } session) + if (context.Console is IMaintenanceConsole { Session: { Principal: null } session }) { session.Principal = new GenericPrincipal(session.Identity, roles: null); } diff --git a/src/DotNext.MaintenanceServices/Maintenance/CommandLine/Authorization/AuthorizationCallback.cs b/src/DotNext.MaintenanceServices/Maintenance/CommandLine/Authorization/AuthorizationCallback.cs index 0ff441c6c..8e00fd884 100644 --- a/src/DotNext.MaintenanceServices/Maintenance/CommandLine/Authorization/AuthorizationCallback.cs +++ b/src/DotNext.MaintenanceServices/Maintenance/CommandLine/Authorization/AuthorizationCallback.cs @@ -3,6 +3,8 @@ namespace DotNext.Maintenance.CommandLine.Authorization; +using Collections.Specialized; + /// /// Represents authorization rule. /// @@ -11,4 +13,4 @@ namespace DotNext.Maintenance.CommandLine.Authorization; /// Maintenance session context. /// The token that can be used to cancel the operation. /// if authorization passed successfully; otherwise, . -public delegate ValueTask AuthorizationCallback(IPrincipal principal, CommandResult target, IDictionary context, CancellationToken token); \ No newline at end of file +public delegate ValueTask AuthorizationCallback(IPrincipal principal, CommandResult target, ITypeMap context, CancellationToken token); \ No newline at end of file diff --git a/src/DotNext.MaintenanceServices/Maintenance/IMaintenanceSession.cs b/src/DotNext.MaintenanceServices/Maintenance/IMaintenanceSession.cs index ee6de1006..282cd3610 100644 --- a/src/DotNext.MaintenanceServices/Maintenance/IMaintenanceSession.cs +++ b/src/DotNext.MaintenanceServices/Maintenance/IMaintenanceSession.cs @@ -2,6 +2,8 @@ namespace DotNext.Maintenance; +using Collections.Specialized; + /// /// Represents AMI interaction session. /// @@ -15,7 +17,7 @@ public interface IMaintenanceSession /// /// Gets a context that can be used to exchange information between command executions. /// - IDictionary Context { get; } + ITypeMap Context { get; } /// /// Gets command response writer.