Webiant Logo Webiant Logo
  1. No results found.

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

DataProviderManager.cs

using Nop.Core;
using Nop.Core.Infrastructure;
using Nop.Data.Configuration;
using Nop.Data.DataProviders;

namespace Nop.Data;

/// 
/// Represents the data provider manager
/// 
public partial class DataProviderManager : IDataProviderManager
{
    #region Methods

    /// 
    /// Gets data provider by specific type
    /// 
    /// Data provider type
    /// 
    public static INopDataProvider GetDataProvider(DataProviderType dataProviderType)
    {
        return dataProviderType switch
        {
            DataProviderType.SqlServer => new MsSqlNopDataProvider(),
            DataProviderType.MySql => new MySqlNopDataProvider(),
            DataProviderType.PostgreSQL => new PostgreSqlDataProvider(),
            _ => throw new NopException($"Not supported data provider name: '{dataProviderType}'"),
        };
    }

    #endregion

    #region Properties

    /// 
    /// Gets data provider
    /// 
    public INopDataProvider DataProvider
    {
        get
        {
            var dataProviderType = Singleton.Instance.DataProvider;

            return GetDataProvider(dataProviderType);
        }
    }

    #endregion
}