using System.Runtime.CompilerServices; namespace Nop.Core.Infrastructure; /// /// Provides access to the singleton instance of the Nop engine. /// public partial class EngineContext { #region Methods /// /// Create a static instance of the Nop engine. /// [MethodImpl(MethodImplOptions.Synchronized)] public static IEngine Create() { //create NopEngine as engine return Singleton.Instance ?? (Singleton.Instance = new NopEngine()); } /// /// Sets the static engine instance to the supplied engine. Use this method to supply your own engine implementation. /// /// The engine to use. /// Only use this method if you know what you're doing. public static void Replace(IEngine engine) { Singleton.Instance = engine; } #endregion #region Properties /// /// Gets the singleton Nop engine used to access Nop services. /// public static IEngine Current { get { if (Singleton.Instance == null) { Create(); } return Singleton.Instance; } } #endregion }