Skip to content

#3930 - Fix for main branch removing api controller attributes which … #3933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Source/Csla.AspNetCore/Blazor/State/StateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ namespace Csla.AspNetCore.Blazor.State
/// </summary>
/// <param name="applicationContext"></param>
/// <param name="sessionManager"></param>
[ApiController]
[Route("[controller]")]
public class StateController(ApplicationContext applicationContext, ISessionManager sessionManager) : ControllerBase
{
/// <summary>
Expand Down
17 changes: 13 additions & 4 deletions Source/Csla.Blazor/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//-----------------------------------------------------------------------

using Csla.Blazor;
using Csla.Blazor.State;
using Csla.Core;
using Csla.State;
using Microsoft.AspNetCore.Authorization;
Expand Down Expand Up @@ -56,10 +57,18 @@ public static CslaOptions AddServerSideBlazor(this CslaOptions config, Action<Bl
config.Services.Remove(manager);
config.Services.AddScoped(typeof(IContextManager), managerType);

// use Blazor state management
config.Services.AddTransient(typeof(ISessionIdManager), blazorOptions.SessionIdManagerType);
config.Services.AddSingleton(typeof(ISessionManager), blazorOptions.SessionManagerType);
config.Services.AddTransient<Blazor.State.StateManager>();
if (blazorOptions.UseInMemoryApplicationContextManager)
{
// do not use any Blazor state management
config.Services.AddSingleton<ISessionManager, NoOpSessionManager>();
}
else
{
// use Blazor state management
config.Services.AddTransient(typeof(ISessionIdManager), blazorOptions.SessionIdManagerType);
config.Services.AddSingleton(typeof(ISessionManager), blazorOptions.SessionManagerType);
config.Services.AddTransient<StateManager>();
}

// use Blazor viewmodel
config.Services.TryAddTransient(typeof(ViewModel<>), typeof(ViewModel<>));
Expand Down
79 changes: 79 additions & 0 deletions Source/Csla.Blazor/State/NoOpSessionManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//-----------------------------------------------------------------------
// <copyright file="NoOpSessionManager.cs" company="Marimer LLC">
// Copyright (c) Marimer LLC. All rights reserved.
// Website: https://cslanet.com
// </copyright>
// <summary>NoOp user session data implementation</summary>
//-----------------------------------------------------------------------

using Csla.State;

namespace Csla.Blazor.State
{
/// <summary>
/// If <see cref="Configuration.BlazorServerConfigurationOptions.UseInMemoryApplicationContextManager"/> is set to <see langword="true"/> then this class
/// will be registered with DI as the default implementation of <see cref="ISessionManager"/>, because in that scenario there should be NO references to any
/// of the state or session management mechanisms which support the flow of <see cref="ApplicationContext"/> between Server-Interactive and WASM-Interactive code.
/// </summary>
public class NoOpSessionManager : ISessionManager
{
/// <summary>
/// Not supported
/// </summary>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
public Session GetCachedSession()
{ throw new NotSupportedException(); }
/// <summary>
/// Not supported
/// </summary>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
public Session GetSession()
{ throw new NotSupportedException(); }
/// <summary>
/// Not supported
/// </summary>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
public void PurgeSessions(TimeSpan expiration)
{ throw new NotSupportedException(); }
/// <summary>
/// Not supported
/// </summary>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
public Task<Session> RetrieveSession()
{ throw new NotSupportedException(); }
/// <summary>
///
/// </summary>
/// <param name="timeout"></param>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
public Task<Session> RetrieveSession(TimeSpan timeout)
{ throw new NotSupportedException(); }
/// <summary>
/// Not supported
/// </summary>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
public Task SendSession()
{ throw new NotSupportedException(); }
/// <summary>
/// Not supported
/// </summary>
/// <param name="timeout"></param>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
public Task SendSession(TimeSpan timeout)
{ throw new NotSupportedException(); }
/// <summary>
/// Not supported
/// </summary>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
public void UpdateSession(Session newSession)
{ throw new NotSupportedException(); }
}
}
Loading