コード例 #1
0
        public void TestGetCached()
        {
            var catalog = CatalogTest.CreateTestCatalog();

            catalog.Normalize();

            _sut.GetCached().Should().BeNull();
            TestGetOnline();
            _sut.GetCached().Should().Be(catalog);
        }
コード例 #2
0
        public static Catalog GetCachedSafe([NotNull] this ICatalogManager manager)
        {
            #region Sanity checks
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }
            #endregion

            try
            {
                return(manager.GetCached() ?? new Catalog());
            }
            #region Error handling
            catch (IOException ex)
            {
                Log.Warn(ex.Message);
                return(new Catalog());
            }
            catch (UnauthorizedAccessException ex)
            {
                Log.Warn(ex.Message);
                return(new Catalog());
            }
            catch (InvalidDataException ex)
            {
                Log.Warn(ex.Message);
                return(new Catalog());
            }
            #endregion
        }
コード例 #3
0
    public static Catalog GetCachedSafe(this ICatalogManager manager)
    {
        #region Sanity checks
        if (manager == null)
        {
            throw new ArgumentNullException(nameof(manager));
        }
        #endregion

        try
        {
            return(manager.GetCached() ?? new());
        }
        #region Error handling
        catch (Exception ex) when(ex is IOException or UnauthorizedAccessException or InvalidDataException)
        {
            Log.Warn(Resources.ErrorLoadingCatalog, ex);
            return(new());
        }
        #endregion
    }