Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

Singleton.cs

namespace Nop.Core.Infrastructure;

/// 
/// A statically compiled "singleton" used to store objects throughout the 
/// lifetime of the app domain. Not so much singleton in the pattern's 
/// sense of the word as a standardized way to store single instances.
/// 
/// The type of object to store.
/// Access to the instance is not synchronized.
public partial class Singleton : BaseSingleton
{
    private static T _instance;

    /// 
    /// The singleton instance for the specified type T. Only one instance (at the time) of this object for each type of T.
    /// 
    public static T Instance
    {
        get => _instance;
        set
        {
            _instance = value;
            AllSingletons[typeof(T)] = value;
        }
    }
}