Beispiel #1
0
        public static Catalog GetOnlineSafe([NotNull] this ICatalogManager manager)
        {
            #region Sanity checks
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }
            #endregion

            try
            {
                return(manager.GetOnline());
            }
            #region Error handling
            catch (IOException ex)
            {
                Log.Warn(ex);
                return(new Catalog());
            }
            catch (WebException ex)
            {
                Log.Warn(ex);
                return(new Catalog());
            }
            catch (InvalidDataException ex)
            {
                Log.Warn(ex);
                return(new Catalog());
            }
            catch (SignatureException ex)
            {
                Log.Warn(ex);
                return(new Catalog());
            }
            catch (UriFormatException ex)
            {
                Log.Warn(ex);
                return(new Catalog());
            }
            #endregion
        }
        public void TestGetOnline()
        {
            var catalog = CatalogTest.CreateTestCatalog();

            catalog.Normalize();

            var catalogStream = new MemoryStream();

            catalog.SaveXml(catalogStream);
            var array = catalogStream.ToArray();

            catalogStream.Position = 0;

            using var server = new MicroServer("catalog.xml", catalogStream);
            var uri = new FeedUri(server.FileUri);

            CatalogManager.SetSources(new[] { uri });
            _trustManagerMock.Setup(x => x.CheckTrust(array, uri, null)).Returns(OpenPgpUtilsTest.TestSignature);

            _sut.GetOnline().Should().Be(catalog);
        }
    public static Catalog GetOnlineSafe(this ICatalogManager manager)
    {
        #region Sanity checks
        if (manager == null)
        {
            throw new ArgumentNullException(nameof(manager));
        }
        #endregion

        try
        {
            return(manager.GetOnline());
        }
        #region Error handling
        catch (Exception ex) when(ex is UriFormatException or WebException or IOException or UnauthorizedAccessException or InvalidDataException or SignatureException)
        {
            Log.Warn(Resources.ErrorLoadingCatalog, ex);
            return(new());
        }
        #endregion
    }
}
 public Catalog GetCatalogOnline() => _catalogManager.GetOnline();
 public Catalog GetCatalogOnline()
 {
     return(_catalogManager.GetOnline());
 }