Skip to content

Commit

Permalink
Code cleanup, typos and things like that
Browse files Browse the repository at this point in the history
  • Loading branch information
Kees van Spelde committed Mar 12, 2024
1 parent 7b37520 commit f2dbfd3
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 28 deletions.
14 changes: 8 additions & 6 deletions ChromiumHtmlToPdfLib/Helpers/DocumentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,6 @@ public DocumentHelper(
_imageLoadTimeout = imageLoadTimeout.Value;
_logger?.WriteToLog($"Setting image load timeout to '{_imageLoadTimeout}' milliseconds");
}

public void Dispose()
{
// Just in case
_stopwatch?.Stop();
}
#endregion

#region ParseValue
Expand Down Expand Up @@ -1037,4 +1031,12 @@ private string GetTempFile(string extension)
return Path.Combine(_tempDirectory?.FullName ?? Path.GetTempPath(), tempFile);
}
#endregion

#region Dispose
public void Dispose()
{
// Just in case
_stopwatch?.Stop();
}
#endregion
}
31 changes: 29 additions & 2 deletions ChromiumHtmlToPdfLib/Helpers/FileCacheHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
using System;
//
// FileCacheHandler.cs
//
// Author: Kees van Spelde <[email protected]>
//
// Copyright (c) 2017-2024 Magic-Sessions. (www.magic-sessions.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//


using System;
using System.IO;
using System.Net;
using System.Net.Http;
Expand All @@ -11,7 +38,7 @@
namespace ChromiumHtmlToPdfLib.Helpers;

/// <summary>
/// An <see cref="HttpClientHandler"/> that caches the response when requested
/// A <see cref="HttpClientHandler"/> that caches the response when requested
/// </summary>
internal class FileCacheHandler : HttpClientHandler
{
Expand Down
28 changes: 27 additions & 1 deletion ChromiumHtmlToPdfLib/Helpers/FileManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
using System.Globalization;
//
// FileManager.cs
//
// Author: Kees van Spelde <[email protected]>
//
// Copyright (c) 2017-2024 Magic-Sessions. (www.magic-sessions.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

using System.Globalization;
using System.IO;
using System.Linq;

Expand Down
32 changes: 29 additions & 3 deletions ChromiumHtmlToPdfLib/Helpers/FitPageToContentResult.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
namespace ChromiumHtmlToPdfLib.Helpers;
//
// FitPageToContentResult.cs
//
// Author: Kees van Spelde <[email protected]>
//
// Copyright (c) 2017-2024 Magic-Sessions. (www.magic-sessions.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

namespace ChromiumHtmlToPdfLib.Helpers;

/// <summary>
/// <see cref="DocumentHelper.FitPageToContentAsync"/>
Expand All @@ -12,7 +38,7 @@ internal class FitPageToContentResult
internal bool Success { get; }

/// <summary>
/// <see cref="ConvertUri"/> of the output file"/>
/// <see cref="ConvertUri"/> of the output file
/// </summary>
internal ConvertUri OutputUri { get; }
#endregion
Expand All @@ -22,7 +48,7 @@ internal class FitPageToContentResult
/// Makes this object and sets it's needed properties
/// </summary>
/// <param name="success"><c>true</c> when success otherwise <c>false</c></param>
/// <param name="outputUri"><see cref="ConvertUri"/> of the output file"/></param>
/// <param name="outputUri"><see cref="ConvertUri"/> of the output file</param>
internal FitPageToContentResult(bool success, ConvertUri outputUri)
{
Success = success;
Expand Down
8 changes: 4 additions & 4 deletions ChromiumHtmlToPdfLib/Helpers/PreWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal class PreWrapper

#region Properties
/// <summary>
/// An unique id that can be used to identify the logging of the converter when
/// A unique id that can be used to identify the logging of the converter when
/// calling the code from multiple threads and writing all the logging to the same file
/// </summary>
// ReSharper disable once UnusedAutoPropertyAccessor.Global
Expand All @@ -75,19 +75,19 @@ internal class PreWrapper

/// <summary>
/// When set then this font will be used when &lt;PRE&gt; wrapping.
/// Otherwise the default system font will be used.
/// Otherwise, the default system font will be used.
/// </summary>
public string? FontFamily { get; set; }

/// <summary>
/// When set then this style will be used when &lt;PRE&gt; wrapping.
/// Otherwise the default system font style will be used.
/// Otherwise, the default system font style will be used.
/// </summary>
public string? FontStyle { get; set; }

/// <summary>
/// When set then this font size will be used when &lt;PRE&gt; wrapping.
/// Otherwise the default system font size will be used.
/// Otherwise, the default system font size will be used.
/// </summary>

public string? FontSize { get; set; }
Expand Down
32 changes: 29 additions & 3 deletions ChromiumHtmlToPdfLib/Helpers/SanitizeHtmlResult.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
using System.Collections.Generic;
//
// SanitizeHtmlResult.cs
//
// Author: Kees van Spelde <[email protected]>
//
// Copyright (c) 2017-2024 Magic-Sessions. (www.magic-sessions.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

using System.Collections.Generic;

namespace ChromiumHtmlToPdfLib.Helpers;

Expand All @@ -14,7 +40,7 @@ internal class SanitizeHtmlResult
internal bool Success { get; }

/// <summary>
/// <see cref="ConvertUri"/> of the output file"/>
/// <see cref="ConvertUri"/> of the output file
/// </summary>
internal ConvertUri OutputUri { get; }

Expand All @@ -29,7 +55,7 @@ internal class SanitizeHtmlResult
/// Makes this object and sets it's needed properties
/// </summary>
/// <param name="success"><c>true</c> when success otherwise <c>false</c></param>
/// <param name="outputUri"><see cref="ConvertUri"/> of the output file"/></param>
/// <param name="outputUri"><see cref="ConvertUri"/> of the output file</param>
/// <param name="safeUrls">A list of safe URL's</param>
internal SanitizeHtmlResult(bool success, ConvertUri outputUri, List<string> safeUrls)
{
Expand Down
30 changes: 27 additions & 3 deletions ChromiumHtmlToPdfLib/Helpers/ValidateImagesResult.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
using System.Collections.Generic;
//
// ValidateImagesResult.cs
//
// Author: Kees van Spelde <[email protected]>
//
// Copyright (c) 2017-2024 Magic-Sessions. (www.magic-sessions.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

namespace ChromiumHtmlToPdfLib.Helpers;

Expand All @@ -14,7 +38,7 @@ internal class ValidateImagesResult
internal bool Success { get; }

/// <summary>
/// <see cref="ConvertUri"/> of the output file"/>
/// <see cref="ConvertUri"/> of the output file
/// </summary>
internal ConvertUri OutputUri { get; }
#endregion
Expand All @@ -24,7 +48,7 @@ internal class ValidateImagesResult
/// Makes this object and sets it's needed properties
/// </summary>
/// <param name="success"><c>true</c> when success otherwise <c>false</c></param>
/// <param name="outputUri"><see cref="ConvertUri"/> of the output file"/></param>
/// <param name="outputUri"><see cref="ConvertUri"/> of the output file</param>
internal ValidateImagesResult(bool success, ConvertUri outputUri)
{
Success = success;
Expand Down
28 changes: 27 additions & 1 deletion ChromiumHtmlToPdfLib/Loggers/Console.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
// ReSharper disable UnusedMember.Global
//
// Console.cs
//
// Author: Kees van Spelde <[email protected]>
//
// Copyright (c) 2017-2024 Magic-Sessions. (www.magic-sessions.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

// ReSharper disable UnusedMember.Global
namespace ChromiumHtmlToPdfLib.Loggers;

/// <summary>
Expand Down
28 changes: 27 additions & 1 deletion ChromiumHtmlToPdfLib/Loggers/File.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
namespace ChromiumHtmlToPdfLib.Loggers;
//
// File.cs
//
// Author: Kees van Spelde <[email protected]>
//
// Copyright (c) 2017-2024 Magic-Sessions. (www.magic-sessions.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

namespace ChromiumHtmlToPdfLib.Loggers;

/// <summary>
/// Writes log information to a file
Expand Down
30 changes: 28 additions & 2 deletions ChromiumHtmlToPdfLib/Loggers/Logger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
using System;
//
// Logger.cs
//
// Author: Kees van Spelde <[email protected]>
//
// Copyright (c) 2017-2024 Magic-Sessions. (www.magic-sessions.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

using System;
using Microsoft.Extensions.Logging;

namespace ChromiumHtmlToPdfLib.Loggers;
Expand All @@ -20,7 +46,7 @@ internal class Logger
public ILogger? InternalLogger { get; set; }

/// <summary>
/// An unique id that can be used to identify the logging of the converter when
/// A unique id that can be used to identify the logging of the converter when
/// calling the code from multiple threads and writing all the logging to the same file
/// </summary>
public string? InstanceId { get; set; }
Expand Down
Loading

0 comments on commit f2dbfd3

Please sign in to comment.