IntelligentPlant.Relativity.AspNetCore
2.0.0
dotnet add package IntelligentPlant.Relativity.AspNetCore --version 2.0.0
NuGet\Install-Package IntelligentPlant.Relativity.AspNetCore -Version 2.0.0
<PackageReference Include="IntelligentPlant.Relativity.AspNetCore" Version="2.0.0" />
paket add IntelligentPlant.Relativity.AspNetCore --version 2.0.0
#r "nuget: IntelligentPlant.Relativity.AspNetCore, 2.0.0"
// Install IntelligentPlant.Relativity.AspNetCore as a Cake Addin #addin nuget:?package=IntelligentPlant.Relativity.AspNetCore&version=2.0.0 // Install IntelligentPlant.Relativity.AspNetCore as a Cake Tool #tool nuget:?package=IntelligentPlant.Relativity.AspNetCore&version=2.0.0
IntelligentPlant.Relativity.AspNetCore
This package provides ASP.NET Core middleware for setting RelativityParser.Current
for an HTTP request. This allows timestamps and durations to be parsed anywhere in the request using RelativityParser.Current
.
Getting Started
Registering Time Zone Providers
The middleware uses time zone providers (derived from TimeZoneProvider
) to determine the time zone to use when configuring the Relativity parser for the request. Use the extension methods defined in RelativityBuilderExtensions
to register time zone providers for the middleware:
services.AddRelativity()
// Set time zone using 'tz' query string parameter
.AddQueryStringTimeZoneProvider()
// Set time zone using 'X-TimeZone' request header
.AddRequestHeaderTimeZoneProvider();
The middleware will use the first time zone provider that returns a valid time zone. If no time zone provider returns a valid time zone, UTC will be used. The order of precedence for the time zone providers from most-specific to least-specific is as follows:
- Custom time zone providers, in registration order
- Query string
- Cookie
- Request header
- User claim
Registering the Middleware
To register the middleware, use the UseRelativity()
extension method for the IApplicationBuilder
class:
app.UseRelativity();
If you are using request localization, you should register the middleware after the request localization middleware to ensure that the culture for the request is set before the Relativity parser is configured:
app.UseRequestLocalization();
app.UseRelativity();
Using the Parser
You can access the parser for the current request using RelativityParser.Current
. For example:
var dt = RelativityParser.Current.ConvertToUtcDateTime("DAY+6H");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.0 | 74 | 10/22/2024 |
2.0.0-pre.13 | 49 | 10/21/2024 |
2.0.0-pre.12 | 53 | 10/21/2024 |
2.0.0-pre.11 | 66 | 3/1/2024 |
2.0.0-pre.10 | 57 | 2/29/2024 |
2.0.0-pre.9 | 53 | 2/29/2024 |
2.0.0-pre.8 | 51 | 2/29/2024 |
2.0.0-pre.7 | 63 | 2/29/2024 |
2.0.0-pre.4 | 50 | 2/29/2024 |
2.0.0-pre.3 | 51 | 2/28/2024 |