Try your search with a different keyword or use * as a wildcard.
using System.Text;
using Newtonsoft.Json;
using Nop.Core.Infrastructure;
namespace Nop.Services.Media.RoxyFileman;
///
/// Represents errors that occur when working with uploaded files
///
public partial class RoxyFilemanException : Exception
{
#region Fields
protected static Dictionary _languageResources;
#endregion
#region Ctor
private RoxyFilemanException() : base()
{
}
///
/// Initializes a new instance of the RoxyFilemanException
///
/// Roxy language resource key
public RoxyFilemanException(string key) : base(GetLocalizedMessage(key))
{
}
///
/// Initializes a new instance of the RoxyFilemanException
///
/// Roxy language resource key
/// The exception that is the cause of the current exception
public RoxyFilemanException(string key, Exception innerException) : base(GetLocalizedMessage(key), innerException)
{
}
#endregion
#region Utilities
///
/// Get the language resource value
///
/// Language resource key
///
/// The language resource value
///
protected static string GetLocalizedMessage(string key)
{
var fileProvider = EngineContext.Current.Resolve();
var roxyConfig = Singleton.Instance;
var languageFile = fileProvider.GetAbsolutePath($"{NopRoxyFilemanDefaults.LanguageDirectory}/{roxyConfig.LANG}.json");
if (!fileProvider.FileExists(languageFile))
languageFile = fileProvider.GetAbsolutePath($"{NopRoxyFilemanDefaults.LanguageDirectory}/en.json");
if (_languageResources is null)
{
var json = fileProvider.ReadAllTextAsync(languageFile, Encoding.UTF8).Result;
_languageResources = JsonConvert.DeserializeObject>(json);
}
if (_languageResources is null)
return key;
if (_languageResources.TryGetValue(key, out var value))
return value;
return key;
}
#endregion
}