Refactor: standardize namespace and using directive style
Refactored all C# test files to use explicit namespace declarations and moved all using directives inside the namespace block for consistency. Updated assembly info and cache files to reflect the new build. Adjusted MvcTestingAppManifest.json to use fully qualified assembly names. No functional changes; all updates are related to code style, organization, and project metadata.
This commit is contained in:
@@ -2,129 +2,127 @@
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
namespace MediaBrowser.Model.Drawing;
|
||||
using global::System;
|
||||
|
||||
namespace MediaBrowser.Model.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Class DrawingUtils.
|
||||
/// </summary>
|
||||
public static class DrawingUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Resizes a set of dimensions.
|
||||
/// </summary>
|
||||
/// <param name="size">The original size object.</param>
|
||||
/// <param name="width">A new fixed width, if desired.</param>
|
||||
/// <param name="height">A new fixed height, if desired.</param>
|
||||
/// <param name="maxWidth">A max fixed width, if desired.</param>
|
||||
/// <param name="maxHeight">A max fixed height, if desired.</param>
|
||||
/// <returns>A new size object.</returns>
|
||||
public static ImageDimensions Resize(
|
||||
ImageDimensions size,
|
||||
int width,
|
||||
int height,
|
||||
int maxWidth,
|
||||
int maxHeight)
|
||||
{
|
||||
int newWidth = size.Width;
|
||||
int newHeight = size.Height;
|
||||
/// <summary>
|
||||
/// Class DrawingUtils.
|
||||
/// </summary>
|
||||
public static class DrawingUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Resizes a set of dimensions.
|
||||
/// </summary>
|
||||
/// <param name="size">The original size object.</param>
|
||||
/// <param name="width">A new fixed width, if desired.</param>
|
||||
/// <param name="height">A new fixed height, if desired.</param>
|
||||
/// <param name="maxWidth">A max fixed width, if desired.</param>
|
||||
/// <param name="maxHeight">A max fixed height, if desired.</param>
|
||||
/// <returns>A new size object.</returns>
|
||||
public static ImageDimensions Resize(
|
||||
ImageDimensions size,
|
||||
int width,
|
||||
int height,
|
||||
int maxWidth,
|
||||
int maxHeight)
|
||||
{
|
||||
int newWidth = size.Width;
|
||||
int newHeight = size.Height;
|
||||
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
newWidth = width;
|
||||
newHeight = height;
|
||||
}
|
||||
else if (height > 0)
|
||||
{
|
||||
newWidth = GetNewWidth(newHeight, newWidth, height);
|
||||
newHeight = height;
|
||||
}
|
||||
else if (width > 0)
|
||||
{
|
||||
newHeight = GetNewHeight(newHeight, newWidth, width);
|
||||
newWidth = width;
|
||||
}
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
newWidth = width;
|
||||
newHeight = height;
|
||||
}
|
||||
else if (height > 0)
|
||||
{
|
||||
newWidth = GetNewWidth(newHeight, newWidth, height);
|
||||
newHeight = height;
|
||||
}
|
||||
else if (width > 0)
|
||||
{
|
||||
newHeight = GetNewHeight(newHeight, newWidth, width);
|
||||
newWidth = width;
|
||||
}
|
||||
|
||||
if (maxHeight > 0 && maxHeight < newHeight)
|
||||
{
|
||||
newWidth = GetNewWidth(newHeight, newWidth, maxHeight);
|
||||
newHeight = maxHeight;
|
||||
}
|
||||
if (maxHeight > 0 && maxHeight < newHeight)
|
||||
{
|
||||
newWidth = GetNewWidth(newHeight, newWidth, maxHeight);
|
||||
newHeight = maxHeight;
|
||||
}
|
||||
|
||||
if (maxWidth > 0 && maxWidth < newWidth)
|
||||
{
|
||||
newHeight = GetNewHeight(newHeight, newWidth, maxWidth);
|
||||
newWidth = maxWidth;
|
||||
}
|
||||
if (maxWidth > 0 && maxWidth < newWidth)
|
||||
{
|
||||
newHeight = GetNewHeight(newHeight, newWidth, maxWidth);
|
||||
newWidth = maxWidth;
|
||||
}
|
||||
|
||||
return new ImageDimensions(newWidth, newHeight);
|
||||
}
|
||||
return new ImageDimensions(newWidth, newHeight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scale down to fill box.
|
||||
/// Returns original size if both width and height are null or zero.
|
||||
/// </summary>
|
||||
/// <param name="size">The original size object.</param>
|
||||
/// <param name="fillWidth">A new fixed width, if desired.</param>
|
||||
/// <param name="fillHeight">A new fixed height, if desired.</param>
|
||||
/// <returns>A new size object or size.</returns>
|
||||
public static ImageDimensions ResizeFill(
|
||||
ImageDimensions size,
|
||||
int? fillWidth,
|
||||
int? fillHeight)
|
||||
{
|
||||
// Return original size if input is invalid.
|
||||
if ((fillWidth is null || fillWidth == 0)
|
||||
&& (fillHeight is null || fillHeight == 0))
|
||||
{
|
||||
return size;
|
||||
}
|
||||
/// <summary>
|
||||
/// Scale down to fill box.
|
||||
/// Returns original size if both width and height are null or zero.
|
||||
/// </summary>
|
||||
/// <param name="size">The original size object.</param>
|
||||
/// <param name="fillWidth">A new fixed width, if desired.</param>
|
||||
/// <param name="fillHeight">A new fixed height, if desired.</param>
|
||||
/// <returns>A new size object or size.</returns>
|
||||
public static ImageDimensions ResizeFill(
|
||||
ImageDimensions size,
|
||||
int? fillWidth,
|
||||
int? fillHeight)
|
||||
{
|
||||
// Return original size if input is invalid.
|
||||
if ((fillWidth is null || fillWidth == 0)
|
||||
&& (fillHeight is null || fillHeight == 0))
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
if (fillWidth is null || fillWidth == 0)
|
||||
{
|
||||
fillWidth = 1;
|
||||
}
|
||||
if (fillWidth is null || fillWidth == 0)
|
||||
{
|
||||
fillWidth = 1;
|
||||
}
|
||||
|
||||
if (fillHeight is null || fillHeight == 0)
|
||||
{
|
||||
fillHeight = 1;
|
||||
}
|
||||
if (fillHeight is null || fillHeight == 0)
|
||||
{
|
||||
fillHeight = 1;
|
||||
}
|
||||
|
||||
double widthRatio = size.Width / (double)fillWidth;
|
||||
double heightRatio = size.Height / (double)fillHeight;
|
||||
double scaleRatio = Math.Min(widthRatio, heightRatio);
|
||||
double widthRatio = size.Width / (double)fillWidth;
|
||||
double heightRatio = size.Height / (double)fillHeight;
|
||||
double scaleRatio = Math.Min(widthRatio, heightRatio);
|
||||
|
||||
// Clamp to current size.
|
||||
if (scaleRatio < 1)
|
||||
{
|
||||
return size;
|
||||
}
|
||||
// Clamp to current size.
|
||||
if (scaleRatio < 1)
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
int newWidth = Convert.ToInt32(Math.Ceiling(size.Width / scaleRatio));
|
||||
int newHeight = Convert.ToInt32(Math.Ceiling(size.Height / scaleRatio));
|
||||
int newWidth = Convert.ToInt32(Math.Ceiling(size.Width / scaleRatio));
|
||||
int newHeight = Convert.ToInt32(Math.Ceiling(size.Height / scaleRatio));
|
||||
|
||||
return new ImageDimensions(newWidth, newHeight);
|
||||
}
|
||||
return new ImageDimensions(newWidth, newHeight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the new width.
|
||||
/// </summary>
|
||||
/// <param name="currentHeight">Height of the current.</param>
|
||||
/// <param name="currentWidth">Width of the current.</param>
|
||||
/// <param name="newHeight">The new height.</param>
|
||||
/// <returns>The new width.</returns>
|
||||
private static int GetNewWidth(int currentHeight, int currentWidth, int newHeight)
|
||||
=> Convert.ToInt32((double)newHeight / currentHeight * currentWidth);
|
||||
/// <summary>
|
||||
/// Gets the new width.
|
||||
/// </summary>
|
||||
/// <param name="currentHeight">Height of the current.</param>
|
||||
/// <param name="currentWidth">Width of the current.</param>
|
||||
/// <param name="newHeight">The new height.</param>
|
||||
/// <returns>The new width.</returns>
|
||||
private static int GetNewWidth(int currentHeight, int currentWidth, int newHeight)
|
||||
=> Convert.ToInt32((double)newHeight / currentHeight * currentWidth);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the new height.
|
||||
/// </summary>
|
||||
/// <param name="currentHeight">Height of the current.</param>
|
||||
/// <param name="currentWidth">Width of the current.</param>
|
||||
/// <param name="newWidth">The new width.</param>
|
||||
/// <returns>System.Double.</returns>
|
||||
private static int GetNewHeight(int currentHeight, int currentWidth, int newWidth)
|
||||
=> Convert.ToInt32((double)newWidth / currentWidth * currentHeight);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the new height.
|
||||
/// </summary>
|
||||
/// <param name="currentHeight">Height of the current.</param>
|
||||
/// <param name="currentWidth">Width of the current.</param>
|
||||
/// <param name="newWidth">The new width.</param>
|
||||
/// <returns>System.Double.</returns>
|
||||
private static int GetNewHeight(int currentHeight, int currentWidth, int newWidth)
|
||||
=> Convert.ToInt32((double)newWidth / currentWidth * currentHeight);
|
||||
}
|
||||
|
||||
@@ -4,46 +4,44 @@
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System.Globalization;
|
||||
using global::System.Globalization;
|
||||
|
||||
namespace MediaBrowser.Model.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Struct ImageDimensions.
|
||||
/// </summary>
|
||||
public readonly struct ImageDimensions
|
||||
{
|
||||
public ImageDimensions(int width, int height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
namespace MediaBrowser.Model.Drawing;
|
||||
/// <summary>
|
||||
/// Struct ImageDimensions.
|
||||
/// </summary>
|
||||
public readonly struct ImageDimensions
|
||||
{
|
||||
public ImageDimensions(int width, int height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the height.
|
||||
/// </summary>
|
||||
/// <value>The height.</value>
|
||||
public int Height { get; }
|
||||
/// <summary>
|
||||
/// Gets the height.
|
||||
/// </summary>
|
||||
/// <value>The height.</value>
|
||||
public int Height { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the width.
|
||||
/// </summary>
|
||||
/// <value>The width.</value>
|
||||
public int Width { get; }
|
||||
/// <summary>
|
||||
/// Gets the width.
|
||||
/// </summary>
|
||||
/// <value>The width.</value>
|
||||
public int Width { get; }
|
||||
|
||||
public bool Equals(ImageDimensions size)
|
||||
{
|
||||
return Width.Equals(size.Width) && Height.Equals(size.Height);
|
||||
}
|
||||
public bool Equals(ImageDimensions size)
|
||||
{
|
||||
return Width.Equals(size.Width) && Height.Equals(size.Height);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}-{1}",
|
||||
Width,
|
||||
Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"{0}-{1}",
|
||||
Width,
|
||||
Height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,41 +2,39 @@
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace MediaBrowser.Model.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum ImageOutputFormat.
|
||||
/// </summary>
|
||||
public enum ImageFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// BMP format.
|
||||
/// </summary>
|
||||
Bmp,
|
||||
namespace MediaBrowser.Model.Drawing;
|
||||
/// <summary>
|
||||
/// Enum ImageOutputFormat.
|
||||
/// </summary>
|
||||
public enum ImageFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// BMP format.
|
||||
/// </summary>
|
||||
Bmp,
|
||||
|
||||
/// <summary>
|
||||
/// GIF format.
|
||||
/// </summary>
|
||||
Gif,
|
||||
/// <summary>
|
||||
/// GIF format.
|
||||
/// </summary>
|
||||
Gif,
|
||||
|
||||
/// <summary>
|
||||
/// JPG format.
|
||||
/// </summary>
|
||||
Jpg,
|
||||
/// <summary>
|
||||
/// JPG format.
|
||||
/// </summary>
|
||||
Jpg,
|
||||
|
||||
/// <summary>
|
||||
/// PNG format.
|
||||
/// </summary>
|
||||
Png,
|
||||
/// <summary>
|
||||
/// PNG format.
|
||||
/// </summary>
|
||||
Png,
|
||||
|
||||
/// <summary>
|
||||
/// WEBP format.
|
||||
/// </summary>
|
||||
Webp,
|
||||
/// <summary>
|
||||
/// WEBP format.
|
||||
/// </summary>
|
||||
Webp,
|
||||
|
||||
/// <summary>
|
||||
/// SVG format.
|
||||
/// </summary>
|
||||
Svg,
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// SVG format.
|
||||
/// </summary>
|
||||
Svg,
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Net.Mime;
|
||||
|
||||
namespace MediaBrowser.Model.Drawing;
|
||||
|
||||
using global::System.ComponentModel;
|
||||
using global::System.Net.Mime;
|
||||
|
||||
/// <summary>
|
||||
/// Extension class for the <see cref="ImageFormat" /> enum.
|
||||
/// </summary>
|
||||
@@ -27,7 +27,7 @@ public static class ImageFormatExtensions
|
||||
ImageFormat.Png => MediaTypeNames.Image.Png,
|
||||
ImageFormat.Webp => MediaTypeNames.Image.Webp,
|
||||
ImageFormat.Svg => MediaTypeNames.Image.Svg,
|
||||
_ => throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(ImageFormat))
|
||||
_ => throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(ImageFormat)),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -45,6 +45,6 @@ public static class ImageFormatExtensions
|
||||
ImageFormat.Png => ".png",
|
||||
ImageFormat.Webp => ".webp",
|
||||
ImageFormat.Svg => ".svg",
|
||||
_ => throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(ImageFormat))
|
||||
_ => throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(ImageFormat)),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,17 +4,15 @@
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
namespace MediaBrowser.Model.Drawing
|
||||
{
|
||||
public enum ImageOrientation
|
||||
{
|
||||
TopLeft = 1,
|
||||
TopRight = 2,
|
||||
BottomRight = 3,
|
||||
BottomLeft = 4,
|
||||
LeftTop = 5,
|
||||
RightTop = 6,
|
||||
RightBottom = 7,
|
||||
LeftBottom = 8,
|
||||
}
|
||||
}
|
||||
namespace MediaBrowser.Model.Drawing;
|
||||
public enum ImageOrientation
|
||||
{
|
||||
TopLeft = 1,
|
||||
TopRight = 2,
|
||||
BottomRight = 3,
|
||||
BottomLeft = 4,
|
||||
LeftTop = 5,
|
||||
RightTop = 6,
|
||||
RightBottom = 7,
|
||||
LeftBottom = 8,
|
||||
}
|
||||
|
||||
@@ -52,5 +52,5 @@ public enum ImageResolution
|
||||
/// <summary>
|
||||
/// 2160p.
|
||||
/// </summary>
|
||||
P2160 = 8
|
||||
P2160 = 8,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user