Skip to content

Commit

Permalink
Remove unused stuff and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sungaila committed Mar 15, 2024
1 parent ad49f2a commit 981ac8e
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 370 deletions.
2 changes: 0 additions & 2 deletions src/FrameworkTests/MauiApp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ private async void OnCounterClicked(object sender, EventArgs e)
using var ms = new MemoryStream();
input.CopyTo(ms);

#pragma warning disable CA1416 // Validate platform compatibility
using var bitmap = PDFtoImage.Conversion.ToImage(ms);
#pragma warning restore CA1416 // Validate platform compatibility

OutputLabel.Text = $"SocialPreview.pdf size: {bitmap.Width}x{bitmap.Height}";
}
Expand Down
4 changes: 1 addition & 3 deletions src/FrameworkTests/Uwp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ public App()

protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;

if (rootFrame == null)
if (!(Window.Current.Content is Frame rootFrame))
{
rootFrame = new Frame();

Expand Down
18 changes: 9 additions & 9 deletions src/PDFtoImage/Exceptions/PdfCannotOpenFileException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace PDFtoImage.Exceptions
{
/// <summary>
/// Thrown if the PDF file was not found or could not be opened.
/// </summary>
public class PdfCannotOpenFileException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.FILE;
/// <summary>
/// Thrown if the PDF file was not found or could not be opened.
/// </summary>
public class PdfCannotOpenFileException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.FILE;

/// <inheritdoc/>
public PdfCannotOpenFileException() : base("File not found or could not be opened.") { }
}
/// <inheritdoc/>
public PdfCannotOpenFileException() : base("File not found or could not be opened.") { }
}
}
40 changes: 19 additions & 21 deletions src/PDFtoImage/Exceptions/PdfException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@

namespace PDFtoImage.Exceptions
{
/// <summary>
/// Base class for all PDF related exceptions.
/// </summary>
public abstract class PdfException : Exception
{
internal abstract FPDF_ERR Error { get; }
/// <summary>
/// Base class for all PDF related exceptions.
/// </summary>
/// <inheritdoc/>
public abstract class PdfException(string message) : Exception(message)
{
internal abstract FPDF_ERR Error { get; }

/// <inheritdoc/>
protected PdfException(string message) : base(message) { }

internal static PdfException? CreateException(FPDF_ERR error) => error switch
{
FPDF_ERR.SUCCESS => null,
FPDF_ERR.UNKNOWN => new PdfUnknownException(),
FPDF_ERR.FILE => new PdfCannotOpenFileException(),
FPDF_ERR.FORMAT => new PdfInvalidFormatException(),
FPDF_ERR.PASSWORD => new PdfPasswordProtectedException(),
FPDF_ERR.SECURITY => new PdfUnsupportedSecuritySchemeException(),
FPDF_ERR.PAGE => new PdfPageNotFoundException(),
_ => new PdfUnknownException()
};
}
internal static PdfException? CreateException(FPDF_ERR error) => error switch
{
FPDF_ERR.SUCCESS => null,
FPDF_ERR.UNKNOWN => new PdfUnknownException(),
FPDF_ERR.FILE => new PdfCannotOpenFileException(),
FPDF_ERR.FORMAT => new PdfInvalidFormatException(),
FPDF_ERR.PASSWORD => new PdfPasswordProtectedException(),
FPDF_ERR.SECURITY => new PdfUnsupportedSecuritySchemeException(),
FPDF_ERR.PAGE => new PdfPageNotFoundException(),
_ => new PdfUnknownException()
};
}
}
18 changes: 9 additions & 9 deletions src/PDFtoImage/Exceptions/PdfInvalidFormatException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace PDFtoImage.Exceptions
{
/// <summary>
/// Thrown if the PDF format is invalid or corrupted.
/// </summary>
public class PdfInvalidFormatException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.FORMAT;
/// <summary>
/// Thrown if the PDF format is invalid or corrupted.
/// </summary>
public class PdfInvalidFormatException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.FORMAT;

/// <inheritdoc/>
public PdfInvalidFormatException() : base("File not in PDF format or corrupted.") { }
}
/// <inheritdoc/>
public PdfInvalidFormatException() : base("File not in PDF format or corrupted.") { }
}
}
18 changes: 9 additions & 9 deletions src/PDFtoImage/Exceptions/PdfPageNotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace PDFtoImage.Exceptions
{
/// <summary>
/// Thrown if the PDF does not contain the given page number.
/// </summary>
public class PdfPageNotFoundException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.PAGE;
/// <summary>
/// Thrown if the PDF does not contain the given page number.
/// </summary>
public class PdfPageNotFoundException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.PAGE;

/// <inheritdoc/>
public PdfPageNotFoundException() : base("Page not found or content error.") { }
}
/// <inheritdoc/>
public PdfPageNotFoundException() : base("Page not found or content error.") { }
}
}
18 changes: 9 additions & 9 deletions src/PDFtoImage/Exceptions/PdfPasswordProtectedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace PDFtoImage.Exceptions
{
/// <summary>
/// Thrown if the PDF requires a password and the given password was not given or incorrect.
/// </summary>
public class PdfPasswordProtectedException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.PASSWORD;
/// <summary>
/// Thrown if the PDF requires a password and the given password was not given or incorrect.
/// </summary>
public class PdfPasswordProtectedException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.PASSWORD;

/// <inheritdoc/>
public PdfPasswordProtectedException() : base("Password required or incorrect password.") { }
}
/// <inheritdoc/>
public PdfPasswordProtectedException() : base("Password required or incorrect password.") { }
}
}
18 changes: 9 additions & 9 deletions src/PDFtoImage/Exceptions/PdfUnknownException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace PDFtoImage.Exceptions
{
/// <summary>
/// Thrown on unknown PDF errors.
/// </summary>
public class PdfUnknownException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.UNKNOWN;
/// <summary>
/// Thrown on unknown PDF errors.
/// </summary>
public class PdfUnknownException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.UNKNOWN;

/// <inheritdoc/>
public PdfUnknownException() : base("Unknown error.") { }
}
/// <inheritdoc/>
public PdfUnknownException() : base("Unknown error.") { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace PDFtoImage.Exceptions
{
/// <summary>
/// Thrown if the PDF file uses an unsupported security scheme.
/// </summary>
public class PdfUnsupportedSecuritySchemeException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.SECURITY;
/// <summary>
/// Thrown if the PDF file uses an unsupported security scheme.
/// </summary>
public class PdfUnsupportedSecuritySchemeException : PdfException
{
internal override FPDF_ERR Error => FPDF_ERR.SECURITY;

/// <inheritdoc/>
public PdfUnsupportedSecuritySchemeException() : base("Unsupported security scheme.") { }
}
/// <inheritdoc/>
public PdfUnsupportedSecuritySchemeException() : base("Unsupported security scheme.") { }
}
}
Loading

0 comments on commit 981ac8e

Please sign in to comment.