Skip to content

Commit

Permalink
Fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Kees committed Mar 1, 2024
1 parent b824f85 commit d7ec214
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ChromiumHtmlToPdfConsole/ChromiumHtmlToPdfConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
<PackageReference Include="AngleSharp.Io" Version="0.17.0" />
<PackageReference Include="AngleSharp.Xml" Version="0.17.0" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions ChromiumHtmlToPdfLib/ChromiumHtmlToPdfLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
<PackageReference Include="AngleSharp.Css" Version="0.17.0" />
<PackageReference Include="AngleSharp.Io" Version="0.17.0" />
<PackageReference Include="AngleSharp.Xml" Version="0.17.0" />
<PackageReference Include="HtmlSanitizer" Version="8.0.746" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="HtmlSanitizer" Version="8.0.843" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Svg" Version="3.4.5" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="System.Management" Version="7.0.2" />
<PackageReference Include="Svg" Version="3.4.7" />
<PackageReference Include="System.Drawing.Common" Version="8.0.2" />
<PackageReference Include="System.Management" Version="8.0.0" />
<PackageReference Include="System.Runtime.Caching" Version="8.0.0" />
<PackageReference Include="UTF.Unknown" Version="2.5.1" />
<PackageReference Include="System.Data.HashFunction.Core" Version="2.0.0" />
Expand Down
3 changes: 1 addition & 2 deletions ChromiumHtmlToPdfLib/FileCache/FileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,7 @@ public override long GetCount(string regionName = null)
}

/// <summary>
/// Will return an enumerator with all cache items listed in the root file path ONLY. Use the other
/// <see cref="GetEnumerator" /> if you want to specify a region
/// Will return an enumerator with all cache items listed in the root file path ONLY
/// </summary>
/// <returns></returns>
protected override IEnumerator<KeyValuePair<string, object>> GetEnumerator()
Expand Down
2 changes: 1 addition & 1 deletion ChromiumHtmlToPdfLib/FileCache/FileCacheBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace ChromiumHtmlToPdfLib.FileCache;

/// <summary>
/// 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.
/// </summary>
internal sealed class FileCacheBinder : SerializationBinder
{
Expand Down
14 changes: 13 additions & 1 deletion ChromiumHtmlToPdfLib/FileCache/FileCacheEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,20 @@

namespace ChromiumHtmlToPdfLib.FileCache;

internal class FileCacheEventArgs(long currentSize, long maxSize) : EventArgs
/// <summary>
/// Used to pass information
/// </summary>
/// <param name="currentSize"></param>
/// <param name="maxSize"></param>
public class FileCacheEventArgs(long currentSize, long maxSize) : EventArgs
{
/// <summary>
/// Returns the current cache size
/// </summary>
public long CurrentCacheSize { get; private set; } = currentSize;

/// <summary>
/// Returns the maximum cache size
/// </summary>
public long MaxCacheSize { get; private set; } = maxSize;
}
49 changes: 48 additions & 1 deletion ChromiumHtmlToPdfLib/FileCache/FileCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,37 @@

namespace ChromiumHtmlToPdfLib.FileCache;

internal abstract class FileCacheManager
/// <summary>
/// An abstract class that provides the basic functionality for a file cache manager
/// </summary>
public abstract class FileCacheManager
{
#region Consts
/// <summary>
/// Represents the current version of the cache file format.
/// </summary>
protected const ulong CacheVersion = 3 << (16 + 3) << (8 + 0) << 0;
#endregion

#region Properties
/// <summary>
/// Returns or sets the directory where the cache will be stored
/// </summary>
public string CacheDir { get; set; }

/// <summary>
/// Returns or sets the subfolder where the cache will be stored
/// </summary>
public string CacheSubFolder { get; set; }

/// <summary>
/// Returns or sets the subfolder where the cache policies will be stored
/// </summary>
public string PolicySubFolder { get; set; }

/// <summary>
/// Returns or sets the serialization binder
/// </summary>
public SerializationBinder Binder { get; set; }

/// <summary>
Expand Down Expand Up @@ -63,6 +84,12 @@ protected void HeaderVersionWrite(BinaryWriter writer)
#endregion

#region DeserializePayloadData
/// <summary>
/// Deserializes the payload data from the specified file
/// </summary>
/// <param name="fileName"></param>
/// <param name="objectBinder"></param>
/// <returns></returns>
protected virtual object DeserializePayloadData(string fileName, SerializationBinder objectBinder = null)
{
object data;
Expand Down Expand Up @@ -90,6 +117,11 @@ protected virtual object DeserializePayloadData(string fileName, SerializationBi
#endregion

#region SerializableCacheItemPolicy
/// <summary>
/// Describes the policy for a cache item
/// </summary>
/// <param name="policyPath"></param>
/// <returns></returns>
protected SerializableCacheItemPolicy DeserializePolicyData(string policyPath)
{
SerializableCacheItemPolicy policy;
Expand Down Expand Up @@ -170,6 +202,12 @@ private byte[] LoadRawPayloadData(string fileName)
#endregion

#region Deserialize
/// <summary>
/// Deserializes the payload data from the specified file
/// </summary>
/// <param name="fileName"></param>
/// <param name="objectBinder"></param>
/// <returns></returns>
protected virtual object Deserialize(string fileName, SerializationBinder objectBinder = null)
{
object data;
Expand Down Expand Up @@ -542,8 +580,17 @@ public virtual long DeleteFile(string key, string regionName = null)
#endregion

#region Class LocalCacheBinder
/// <summary>
/// A custom serialization binder that will be used to deserialize custom objects
/// </summary>
protected class LocalCacheBinder : SerializationBinder
{
/// <summary>
/// Bind the type to a name
/// </summary>
/// <param name="assemblyName"></param>
/// <param name="typeName"></param>
/// <returns></returns>
public override Type BindToType(string assemblyName, string typeName)
{
var currentAssembly = Assembly.GetAssembly(typeof(LocalCacheBinder))!.FullName;
Expand Down
12 changes: 11 additions & 1 deletion ChromiumHtmlToPdfLib/FileCache/FileCacheManagers.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
namespace ChromiumHtmlToPdfLib.FileCache;

internal enum FileCacheManagers
/// <summary>
/// Specifies the type of file cache manager
/// </summary>
public enum FileCacheManagers
{
/// <summary>
/// A basic file cache manager that does not use hashing
/// </summary>
Basic,

/// <summary>
/// A file cache manager that uses hashing
/// </summary>
Hashed
}
10 changes: 9 additions & 1 deletion ChromiumHtmlToPdfLib/FileCache/SerializableCacheItemPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,23 @@ namespace ChromiumHtmlToPdfLib.FileCache;
public class SerializableCacheItemPolicy
{
#region Fields
// Magic version for new policies: 3.3.0 packed into a long.
/// <summary>
/// Magic version for new policies: 3.3.0 packed into a long
/// </summary>
protected const ulong CacheVersion = 3 << (16 + 3) << (8 + 0) << 0;

private TimeSpan _slidingExpiration;
#endregion

#region Properties
/// <summary>
/// Returns or sets the absolute expiration date and time for the cache entry
/// </summary>
public DateTimeOffset AbsoluteExpiration { get; set; }

/// <summary>
/// Returns or sets the sliding expiration time for the cache entry
/// </summary>
public TimeSpan SlidingExpiration
{
get => _slidingExpiration;
Expand Down
1 change: 1 addition & 0 deletions ChromiumHtmlToPdfLib/Loggers/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal class Logger
/// Makes this object and sets all its needed properties
/// </summary>
/// <param name="logger"></param>
/// <param name="instanceId"></param>
internal Logger(ILogger logger, string instanceId)
{
InternalLogger = logger;
Expand Down

0 comments on commit d7ec214

Please sign in to comment.