SharpGrip.FlashMessages 1.0.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package SharpGrip.FlashMessages --version 1.0.0
NuGet\Install-Package SharpGrip.FlashMessages -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SharpGrip.FlashMessages" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SharpGrip.FlashMessages --version 1.0.0
#r "nuget: SharpGrip.FlashMessages, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 NuGet

Builds

FlashMessages [Build]

Quality Gate Status
Maintainability Rating
Reliability Rating
Security Rating
Coverage

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 alert-@message.Type alert-dismissible fade show" role="alert">
            @message.Text
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="true">&times;</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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 195 8/5/2023
1.0.0-alpha1 17,691 3/10/2020