ok
70422a2e284e2b7fc206c82ce4ae1fc517842a44
4 files changed
README.mdSessionScoped/README.mdSessionScoped/SessionScoped.csprojSessionScopedExtension.sln
diff --git a/README.md b/README.md
index dc85700..9e0d5d6 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,120 @@
-# SessionScopedExtension
\ No newline at end of file
+# builder.Services.AddSessionScoped<T>();
+
+A lightweight extension for managing session-scoped data in ASP.NET Core applications.
+
+## Overview
+
+SessionScoped simplifies session management by providing scoped data storage tied to the user's session. It integrates seamlessly with ASP.NET Core's dependency injection, making session-based state management easy and robust.
+
+## Features
+
+- Scoped data tied to the user's session.
+- Fully compatible with ASP.NET Core dependency injection.
+- Minimal setup required.
+
+## Getting Started
+
+1. **Configure AddSessionScoped**
+
+Register the session and `SessionScoped` in your `Startup.cs` or `Program.cs` file:
+
+```csharp
+using SessionScopedTest.Services;
+
+var builder = WebApplication.CreateBuilder(new WebApplicationOptions
+{
+ ContentRootPath = AppContext.BaseDirectory
+});
+
+var services = builder.Services;
+
+services.AddHttpContextAccessor();
+services.AddMvc();
+
+services.AddDistributedMemoryCache();
+services.AddSession(options =>
+{
+ options.IdleTimeout = TimeSpan.FromMinutes(20);
+ options.Cookie.Name = ".AspNetCore.Session";
+ options.Cookie.HttpOnly = true;
+ options.Cookie.IsEssential = true;
+});
+
+services.AddSessionScoped<ExampleService>();
+
+var app = builder.Build();
+
+app.UseDefaultFiles();
+app.UseStaticFiles();
+app.UseSession();
+app.MapDefaultControllerRoute();
+
+app.Run();
+```
+
+2. **Create a Service implementing IHostedService interface**
+
+```csharp
+public class ExampleService(ILoggerFactory loggerFactory) : IHostedService
+{
+ private readonly ILogger Logger = loggerFactory.CreateLogger<ExampleService>();
+
+ public async Task<int> CalcAsync(int a, int b)
+ {
+ Logger.LogInformation("CalcAsync {a} x {b}", a , b);
+
+ await Task.Delay(100);
+
+ return a * b;
+ }
+
+ public async Task StartAsync(CancellationToken cancellationToken)
+ {
+ Logger.LogWarning("StartAsync");
+
+ await Task.Delay(100);
+ }
+
+ public async Task StopAsync(CancellationToken cancellationToken)
+ {
+ Logger.LogWarning("StopAsync");
+
+ await Task.Delay(100);
+ }
+}
+```
+
+3. **Use SessionScopedFactory<T>**
+
+Inject `SessionScopedFactory<ExampleService> factory` into your services or controllers to manage session-scoped data:
+
+```csharp
+public class ExampleController(SessionScopedFactory<ExampleService> factory) : ControllerBase
+{
+ public async Task<IActionResult> Index()
+ {
+ HttpContext.Session.SetString("Started", DateTime.Now.ToString());
+
+ var result = await factory.Instance.CalcAsync(123, 456);
+
+ return Ok(result);
+ }
+}
+```
+
+## Requirements
+
+- .NET 9 or higher
+- ASP.NET Core
+
+## Contributing
+
+Contributions are welcome! Feel free to fork the repository and submit a pull request.
+
+## License
+
+This project is licensed under the MIT License. See the [LICENSE](https://github.com/alphons/SessionScopedExtension/blob/master/LICENSE) file for details.
+
+---
+
+For more details, visit the [GitHub repository](https://github.com/alphons/SessionScopedExtension/tree/master/SessionScoped).
diff --git a/SessionScoped/README.md b/SessionScoped/README.md
deleted file mode 100644
index 0dfa92e..0000000
--- a/SessionScoped/README.md
+++ /dev/null
@@ -1,120 +0,0 @@
-# SessionScoped
-
-A lightweight extension for managing session-scoped data in ASP.NET Core applications.
-
-## Overview
-
-SessionScoped simplifies session management by providing scoped data storage tied to the user's session. It integrates seamlessly with ASP.NET Core's dependency injection, making session-based state management easy and robust.
-
-## Features
-
-- Scoped data tied to the user's session.
-- Fully compatible with ASP.NET Core dependency injection.
-- Minimal setup required.
-
-## Getting Started
-
-1. **Configure AddSessionScoped**
-
-Register the session and `SessionScoped` in your `Startup.cs` or `Program.cs` file:
-
-```csharp
-using SessionScopedTest.Services;
-
-var builder = WebApplication.CreateBuilder(new WebApplicationOptions
-{
- ContentRootPath = AppContext.BaseDirectory
-});
-
-var services = builder.Services;
-
-services.AddHttpContextAccessor();
-services.AddMvc();
-
-services.AddDistributedMemoryCache();
-services.AddSession(options =>
-{
- options.IdleTimeout = TimeSpan.FromMinutes(20);
- options.Cookie.Name = ".AspNetCore.Session";
- options.Cookie.HttpOnly = true;
- options.Cookie.IsEssential = true;
-});
-
-services.AddSessionScoped<ExampleService>();
-
-var app = builder.Build();
-
-app.UseDefaultFiles();
-app.UseStaticFiles();
-app.UseSession();
-app.MapDefaultControllerRoute();
-
-app.Run();
-```
-
-2. **Create a Service implementing IHostedService interface**
-
-```csharp
-public class ExampleService(ILoggerFactory loggerFactory) : IHostedService
-{
- private readonly ILogger Logger = loggerFactory.CreateLogger<ExampleService>();
-
- public async Task<int> CalcAsync(int a, int b)
- {
- Logger.LogInformation("CalcAsync {a} x {b}", a , b);
-
- await Task.Delay(100);
-
- return a * b;
- }
-
- public async Task StartAsync(CancellationToken cancellationToken)
- {
- Logger.LogWarning("StartAsync");
-
- await Task.Delay(100);
- }
-
- public async Task StopAsync(CancellationToken cancellationToken)
- {
- Logger.LogWarning("StopAsync");
-
- await Task.Delay(100);
- }
-}
-```
-
-3. **Use SessionScopedFactory<T>**
-
-Inject `SessionScopedFactory<ExampleService> factory` into your services or controllers to manage session-scoped data:
-
-```csharp
-public class ExampleController(SessionScopedFactory<ExampleService> factory) : ControllerBase
-{
- public async Task<IActionResult> Index()
- {
- HttpContext.Session.SetString("Started", DateTime.Now.ToString());
-
- var result = await factory.Instance.CalcAsync(123, 456);
-
- return Ok(result);
- }
-}
-```
-
-## Requirements
-
-- .NET 9 or higher
-- ASP.NET Core
-
-## Contributing
-
-Contributions are welcome! Feel free to fork the repository and submit a pull request.
-
-## License
-
-This project is licensed under the MIT License. See the [LICENSE](https://github.com/alphons/SessionScopedExtension/blob/master/LICENSE) file for details.
-
----
-
-For more details, visit the [GitHub repository](https://github.com/alphons/SessionScopedExtension/tree/master/SessionScoped).
diff --git a/SessionScoped/SessionScoped.csproj b/SessionScoped/SessionScoped.csproj
index 93ffc9c..fd02a30 100644
--- a/SessionScoped/SessionScoped.csproj
+++ b/SessionScoped/SessionScoped.csproj
@@ -4,7 +4,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>Extensions.DependencyInjection.SessionScoped</PackageId>
- <Version>9.0.0</Version>
+ <Version>9.0.1</Version>
<Authors>Alphons van der Heijden</Authors>
<Description>Adds a session-scoped IHostedService service to the services collection</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
@@ -14,6 +14,10 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
+ <ItemGroup>
+ <None Include="..\README.md" Pack="true" PackagePath="\"/>
+ </ItemGroup>
+
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Session" Version="2.3.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.1" />
diff --git a/SessionScopedExtension.sln b/SessionScopedExtension.sln
index 3f30c32..bc0af47 100644
--- a/SessionScopedExtension.sln
+++ b/SessionScopedExtension.sln
@@ -7,6 +7,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionScoped", "SessionSco
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionScopedTest", "SessionScopedTest\SessionScopedTest.csproj", "{FAD9FE79-92F8-410B-8777-50BEB0A3C670}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{358C711C-8779-4ABC-B6ED-633AE00DDBFC}"
+ ProjectSection(SolutionItems) = preProject
+ README.md = README.md
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU