SharpGrip.FlashMessages
1.0.0
Prefix Reserved
dotnet add package SharpGrip.FlashMessages --version 1.0.0
NuGet\Install-Package SharpGrip.FlashMessages -Version 1.0.0
<PackageReference Include="SharpGrip.FlashMessages" Version="1.0.0" />
paket add SharpGrip.FlashMessages --version 1.0.0
#r "nuget: SharpGrip.FlashMessages, 1.0.0"
// Install SharpGrip.FlashMessages as a Cake Addin #addin nuget:?package=SharpGrip.FlashMessages&version=1.0.0 // Install SharpGrip.FlashMessages as a Cake Tool #tool nuget:?package=SharpGrip.FlashMessages&version=1.0.0
SharpGrip FlashMessages
Builds
Introduction
SharpGrip FlashMessages is a messaging system for adding and reading flash messages.
Installation
Reference NuGet package SharpGrip.FlashMessages
(https://www.nuget.org/packages/SharpGrip.FlashMessages).
Add the FlashMessages messaging system to your service collection via the extension method.
public void ConfigureServices(IServiceCollection services)
{
services.AddFlashMessages();
}
Configuration
Properties
Property | Default value | Description |
---|---|---|
StorageKey | __FlashMessages__ |
The key used to store message data in the ITempDataDictionary session storage. |
Via the services.AddFlashMessages()
extension method
using SharpGrip.FlashMessages.Extensions;
using SharpGrip.FlashMessages.Options;
public void ConfigureServices(IServiceCollection services)
{
services.AddFlashMessages(options =>
{
options.StorageKey = "SomeOtherStorageKey";
});
}
Via the services.Configure()
method
using SharpGrip.FlashMessages.Extensions;
using SharpGrip.FlashMessages.Options;
public void ConfigureServices(IServiceCollection services)
{
services.AddFlashMessages();
services.Configure<FlashMessagesOptions>(options =>
{
options.StorageKey = "SomeOtherStorageKey";
});
}
Usage
Adding messages
Inject the IFlasher
service and call the IFlasher.Add(messageType, message)
method.
flasher.Add("success", "My very first success message!");
flasher.Add("info", "My very first info message!");
flasher.Add("warning", "My very first warning message!");
flasher.Add("danger", "My very first danger message!");
Reading messages
Inject the IFlasher
service and call the IFlasher.GetMessages()
method.
@using SharpGrip.FlashMessages
@inject IFlasher Flasher
<div class="alerts">
@foreach (var message in Flasher.GetMessages())
{
<div class="row alert [email protected] alert-dismissible fade show" role="alert">
@message.Text
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
}
</div>
Peeking at messages
Inject the IFlasher
service and call the IFlasher.PeekMessages()
method. Peeking at messages will not clear the messages present in the message store.
var messages = flasher.PeekMessages();
Clearing messages
Inject the IFlasher
service and call the IFlasher.Clear()
method.
flasher.Clear();
Note: Clearing the message store is not necessary when reading messages via the IFlasher.GetMessages()
method.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.ViewFeatures (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.1.2)
- System.Text.Json (>= 4.7.1)
-
.NETStandard 2.1
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.ViewFeatures (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.1.2)
- System.Text.Json (>= 4.7.1)
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 |
---|---|---|
1.0.0 | 782 | 8/5/2023 |
1.0.0-alpha1 | 17,712 | 3/10/2020 |