SHA256
Refactor Every namespace Keyword Usage
This commit is contained in:
1 parent
4e67cb9b09
commit
27be2141f7
44 files changed
+4619
-4545
No files matched your search
+36
-5
@@ -5,9 +5,10 @@ using System.IO;
|
||||
namespace ADOFAIRenderer.API;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the result and metadata of a completed or cancelled render session.
|
||||
/// Represents the result and metadata of a completed or canceled render session.
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
public class RenderResult
|
||||
{
|
||||
/// <summary>
|
||||
@@ -41,10 +42,20 @@ public class RenderResult
|
||||
public long FileSizeBytes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Error message or reason if rendering failed or was cancelled; <c>null</c> on success.
|
||||
/// Error message or reason if rendering failed or was canceled; <c>null</c> on success.
|
||||
/// </summary>
|
||||
public string? ErrorMessage { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RenderResult"/> class.
|
||||
/// </summary>
|
||||
/// <param name="success">Whether the render session completed successfully.</param>
|
||||
/// <param name="outputPath">The absolute output path of the rendered video file.</param>
|
||||
/// <param name="totalFrames">Total number of video frames sent to the encoder.</param>
|
||||
/// <param name="videoDuration">Calculated video duration in seconds.</param>
|
||||
/// <param name="renderDuration">Total wall-clock time spent rendering.</param>
|
||||
/// <param name="fileSizeBytes">File size of the output video in bytes.</param>
|
||||
/// <param name="errorMessage">Error message or reason if failed or canceled; otherwise, <c>null</c>.</param>
|
||||
public RenderResult(
|
||||
bool success,
|
||||
string outputPath,
|
||||
@@ -63,7 +74,15 @@ public class RenderResult
|
||||
ErrorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public static RenderResult CreateSuccess(string outputPath, long totalFrames, double fps, TimeSpan renderDuration)
|
||||
/// <summary>
|
||||
/// Creates a successful <see cref="RenderResult"/> instance from the specified render metrics.
|
||||
/// </summary>
|
||||
/// <param name="outputPath">The path to the rendered video file.</param>
|
||||
/// <param name="totalFrames">Total number of video frames sent to the encoder.</param>
|
||||
/// <param name="fps">The effective frames per second used to compute video duration.</param>
|
||||
/// <param name="renderDuration">Total wall-clock time spent rendering.</param>
|
||||
/// <returns>A new <see cref="RenderResult"/> representing a successful render session.</returns>
|
||||
internal static RenderResult CreateSuccess(string outputPath, long totalFrames, double fps, TimeSpan renderDuration)
|
||||
{
|
||||
var fileSizeBytes = 0L;
|
||||
if (!string.IsNullOrEmpty(outputPath) && File.Exists(outputPath))
|
||||
@@ -76,12 +95,24 @@ public class RenderResult
|
||||
return new RenderResult(true, outputPath, totalFrames, videoDuration, renderDuration, fileSizeBytes);
|
||||
}
|
||||
|
||||
public static RenderResult CreateFailure(string? errorMessage, long totalFrames, double fps, TimeSpan renderDuration)
|
||||
/// <summary>
|
||||
/// Creates a failed or cancelled <see cref="RenderResult"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="errorMessage">Error message or reason for failure/cancellation.</param>
|
||||
/// <param name="totalFrames">Total number of video frames sent to the encoder prior to termination.</param>
|
||||
/// <param name="fps">The effective frames per second used to compute video duration.</param>
|
||||
/// <param name="renderDuration">Total wall-clock time spent rendering prior to termination.</param>
|
||||
/// <returns>A new <see cref="RenderResult"/> representing a failed or canceled render session.</returns>
|
||||
internal static RenderResult CreateFailure(string? errorMessage, long totalFrames, double fps, TimeSpan renderDuration)
|
||||
{
|
||||
var videoDuration = fps > 0 ? totalFrames / fps : 0.0;
|
||||
return new RenderResult(false, string.Empty, totalFrames, videoDuration, renderDuration, 0, errorMessage ?? "Rendering failed or was cancelled.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string summarizing the render result metrics or failure reason.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of the <see cref="RenderResult"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Success
|
||||
|
||||
@@ -92,12 +92,22 @@ public class RenderSession
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether desktop notifications should be displayed when rendering completes.
|
||||
/// </summary>
|
||||
/// <param name="enabled"><c>true</c> to enable desktop notifications; otherwise, <c>false</c>.</param>
|
||||
/// <returns>The current <see cref="RenderSession"/> instance for method chaining.</returns>
|
||||
public RenderSession WithNotification(bool enabled)
|
||||
{
|
||||
_notification = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a callback action to be invoked when the render session completes or fails.
|
||||
/// </summary>
|
||||
/// <param name="callback">The callback action that receives the resulting <see cref="RenderResult"/>.</param>
|
||||
/// <returns>The current <see cref="RenderSession"/> instance for method chaining.</returns>
|
||||
public RenderSession OnComplete(Action<RenderResult> callback)
|
||||
{
|
||||
_onComplete += callback;
|
||||
@@ -109,6 +119,7 @@ public class RenderSession
|
||||
/// </summary>
|
||||
/// <param name="renderConfig">The configuration settings for the render session.</param>
|
||||
/// <param name="levelPath">The file path of the level to render.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown when the output directory cannot be determined from the output path.</exception>
|
||||
public void Start(RenderConfig renderConfig, string levelPath)
|
||||
{
|
||||
RenderContext.Auto = _auto;
|
||||
|
||||
Reference in new issue
Block a user