public void NonNullFactoryGet() { var currentFactory = UtilResources.Factory; UtilResources.Initialize(new StringLocalizerFactory()); var name = "The database was deleted!"; var resource = UtilResources.Get(name); Assert.AreEqual(name, resource); UtilResources.Initialize(currentFactory); }
public void NonNullFactoryGetWithArgs() { var currentFactory = UtilResources.Factory; UtilResources.Initialize(new StringLocalizerFactory()); var name = "The {0} database couldn´t be deleted!"; var args = "ChuckNorrisFacts"; var resource = UtilResources.Get(name, args); Assert.AreEqual("The ChuckNorrisFacts database couldn´t be deleted!", resource); UtilResources.Initialize(currentFactory); }
/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="args">Encapsulates the properties to initialize a new /// ApiServiceArgs<TLoggerCategory>.</param> /// <exception cref="ArgumentNullException">Args is null.</exception> public ApiService(ApiServiceArgs <TLoggerCategory> args) { if (args == null) { throw new ArgumentNullException( UtilResources.Get("ArgumentCanNotBeNull", nameof(args))); } _stopWatch = new Stopwatch(); _httpContextAccessor = args.HttpContextAccessor; ServiceProvider = args.ServiceProvider; Config = args.Config; Logger = args.Logger; Mapper = args.Mapper; UtilResources.Initialize(args.StringLocalizerFactory); _stringLocalizer = UtilResources.Factory.Create(typeof(TResources)); }