From d7ec214abeb9c5fcede994e0b35fdf6da32e0ab2 Mon Sep 17 00:00:00 2001 From: Kees Date: Fri, 1 Mar 2024 09:07:15 +0100 Subject: [PATCH] Fix some warnings --- .../ChromiumHtmlToPdfConsole.csproj | 4 +- .../ChromiumHtmlToPdfLib.csproj | 10 ++-- ChromiumHtmlToPdfLib/FileCache/FileCache.cs | 3 +- .../FileCache/FileCacheBinder.cs | 2 +- .../FileCache/FileCacheEventArgs.cs | 14 +++++- .../FileCache/FileCacheManager.cs | 49 ++++++++++++++++++- .../FileCache/FileCacheManagers.cs | 12 ++++- .../FileCache/SerializableCacheItemPolicy.cs | 10 +++- ChromiumHtmlToPdfLib/Loggers/Logger.cs | 1 + 9 files changed, 91 insertions(+), 14 deletions(-) diff --git a/ChromiumHtmlToPdfConsole/ChromiumHtmlToPdfConsole.csproj b/ChromiumHtmlToPdfConsole/ChromiumHtmlToPdfConsole.csproj index 6ab15db..b74d1db 100644 --- a/ChromiumHtmlToPdfConsole/ChromiumHtmlToPdfConsole.csproj +++ b/ChromiumHtmlToPdfConsole/ChromiumHtmlToPdfConsole.csproj @@ -36,8 +36,8 @@ - - + + diff --git a/ChromiumHtmlToPdfLib/ChromiumHtmlToPdfLib.csproj b/ChromiumHtmlToPdfLib/ChromiumHtmlToPdfLib.csproj index 30fd39c..7200f20 100644 --- a/ChromiumHtmlToPdfLib/ChromiumHtmlToPdfLib.csproj +++ b/ChromiumHtmlToPdfLib/ChromiumHtmlToPdfLib.csproj @@ -34,13 +34,13 @@ - - + + - - - + + + diff --git a/ChromiumHtmlToPdfLib/FileCache/FileCache.cs b/ChromiumHtmlToPdfLib/FileCache/FileCache.cs index 8cf2018..fffb5d2 100644 --- a/ChromiumHtmlToPdfLib/FileCache/FileCache.cs +++ b/ChromiumHtmlToPdfLib/FileCache/FileCache.cs @@ -1032,8 +1032,7 @@ public override long GetCount(string regionName = null) } /// - /// Will return an enumerator with all cache items listed in the root file path ONLY. Use the other - /// if you want to specify a region + /// Will return an enumerator with all cache items listed in the root file path ONLY /// /// protected override IEnumerator> GetEnumerator() diff --git a/ChromiumHtmlToPdfLib/FileCache/FileCacheBinder.cs b/ChromiumHtmlToPdfLib/FileCache/FileCacheBinder.cs index 7575c93..82eb367 100644 --- a/ChromiumHtmlToPdfLib/FileCache/FileCacheBinder.cs +++ b/ChromiumHtmlToPdfLib/FileCache/FileCacheBinder.cs @@ -14,7 +14,7 @@ namespace ChromiumHtmlToPdfLib.FileCache; /// -/// You should be able to copy & paste this code into your local project to enable caching custom objects. +/// You should be able to copy and paste this code into your local project to enable caching custom objects. /// internal sealed class FileCacheBinder : SerializationBinder { diff --git a/ChromiumHtmlToPdfLib/FileCache/FileCacheEventArgs.cs b/ChromiumHtmlToPdfLib/FileCache/FileCacheEventArgs.cs index 6dae847..b379983 100644 --- a/ChromiumHtmlToPdfLib/FileCache/FileCacheEventArgs.cs +++ b/ChromiumHtmlToPdfLib/FileCache/FileCacheEventArgs.cs @@ -12,8 +12,20 @@ namespace ChromiumHtmlToPdfLib.FileCache; -internal class FileCacheEventArgs(long currentSize, long maxSize) : EventArgs +/// +/// Used to pass information +/// +/// +/// +public class FileCacheEventArgs(long currentSize, long maxSize) : EventArgs { + /// + /// Returns the current cache size + /// public long CurrentCacheSize { get; private set; } = currentSize; + + /// + /// Returns the maximum cache size + /// public long MaxCacheSize { get; private set; } = maxSize; } \ No newline at end of file diff --git a/ChromiumHtmlToPdfLib/FileCache/FileCacheManager.cs b/ChromiumHtmlToPdfLib/FileCache/FileCacheManager.cs index 30a6e66..56dbae7 100644 --- a/ChromiumHtmlToPdfLib/FileCache/FileCacheManager.cs +++ b/ChromiumHtmlToPdfLib/FileCache/FileCacheManager.cs @@ -9,16 +9,37 @@ namespace ChromiumHtmlToPdfLib.FileCache; -internal abstract class FileCacheManager +/// +/// An abstract class that provides the basic functionality for a file cache manager +/// +public abstract class FileCacheManager { #region Consts + /// + /// Represents the current version of the cache file format. + /// protected const ulong CacheVersion = 3 << (16 + 3) << (8 + 0) << 0; #endregion #region Properties + /// + /// Returns or sets the directory where the cache will be stored + /// public string CacheDir { get; set; } + + /// + /// Returns or sets the subfolder where the cache will be stored + /// public string CacheSubFolder { get; set; } + + /// + /// Returns or sets the subfolder where the cache policies will be stored + /// public string PolicySubFolder { get; set; } + + /// + /// Returns or sets the serialization binder + /// public SerializationBinder Binder { get; set; } /// @@ -63,6 +84,12 @@ protected void HeaderVersionWrite(BinaryWriter writer) #endregion #region DeserializePayloadData + /// + /// Deserializes the payload data from the specified file + /// + /// + /// + /// protected virtual object DeserializePayloadData(string fileName, SerializationBinder objectBinder = null) { object data; @@ -90,6 +117,11 @@ protected virtual object DeserializePayloadData(string fileName, SerializationBi #endregion #region SerializableCacheItemPolicy + /// + /// Describes the policy for a cache item + /// + /// + /// protected SerializableCacheItemPolicy DeserializePolicyData(string policyPath) { SerializableCacheItemPolicy policy; @@ -170,6 +202,12 @@ private byte[] LoadRawPayloadData(string fileName) #endregion #region Deserialize + /// + /// Deserializes the payload data from the specified file + /// + /// + /// + /// protected virtual object Deserialize(string fileName, SerializationBinder objectBinder = null) { object data; @@ -542,8 +580,17 @@ public virtual long DeleteFile(string key, string regionName = null) #endregion #region Class LocalCacheBinder + /// + /// A custom serialization binder that will be used to deserialize custom objects + /// protected class LocalCacheBinder : SerializationBinder { + /// + /// Bind the type to a name + /// + /// + /// + /// public override Type BindToType(string assemblyName, string typeName) { var currentAssembly = Assembly.GetAssembly(typeof(LocalCacheBinder))!.FullName; diff --git a/ChromiumHtmlToPdfLib/FileCache/FileCacheManagers.cs b/ChromiumHtmlToPdfLib/FileCache/FileCacheManagers.cs index 24ea736..e5267a5 100644 --- a/ChromiumHtmlToPdfLib/FileCache/FileCacheManagers.cs +++ b/ChromiumHtmlToPdfLib/FileCache/FileCacheManagers.cs @@ -1,7 +1,17 @@ namespace ChromiumHtmlToPdfLib.FileCache; -internal enum FileCacheManagers +/// +/// Specifies the type of file cache manager +/// +public enum FileCacheManagers { + /// + /// A basic file cache manager that does not use hashing + /// Basic, + + /// + /// A file cache manager that uses hashing + /// Hashed } \ No newline at end of file diff --git a/ChromiumHtmlToPdfLib/FileCache/SerializableCacheItemPolicy.cs b/ChromiumHtmlToPdfLib/FileCache/SerializableCacheItemPolicy.cs index 49a76f8..e604bf4 100644 --- a/ChromiumHtmlToPdfLib/FileCache/SerializableCacheItemPolicy.cs +++ b/ChromiumHtmlToPdfLib/FileCache/SerializableCacheItemPolicy.cs @@ -20,15 +20,23 @@ namespace ChromiumHtmlToPdfLib.FileCache; public class SerializableCacheItemPolicy { #region Fields - // Magic version for new policies: 3.3.0 packed into a long. + /// + /// Magic version for new policies: 3.3.0 packed into a long + /// protected const ulong CacheVersion = 3 << (16 + 3) << (8 + 0) << 0; private TimeSpan _slidingExpiration; #endregion #region Properties + /// + /// Returns or sets the absolute expiration date and time for the cache entry + /// public DateTimeOffset AbsoluteExpiration { get; set; } + /// + /// Returns or sets the sliding expiration time for the cache entry + /// public TimeSpan SlidingExpiration { get => _slidingExpiration; diff --git a/ChromiumHtmlToPdfLib/Loggers/Logger.cs b/ChromiumHtmlToPdfLib/Loggers/Logger.cs index f1c3490..7837210 100644 --- a/ChromiumHtmlToPdfLib/Loggers/Logger.cs +++ b/ChromiumHtmlToPdfLib/Loggers/Logger.cs @@ -31,6 +31,7 @@ internal class Logger /// Makes this object and sets all its needed properties /// /// + /// internal Logger(ILogger logger, string instanceId) { InternalLogger = logger;