Skip to content

Commit

Permalink
Code tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnmbond committed Jan 5, 2025
1 parent 764a617 commit 1f15e22
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 183 deletions.
1 change: 1 addition & 0 deletions PanoramicData.Blazor.dic
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ abcdef
alt
App
Blazor
Center
Clickable
Css
dd
Expand Down
22 changes: 22 additions & 0 deletions PanoramicData.Blazor/Arguments/DropZoneAllProgressEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace PanoramicData.Blazor.Arguments;

/// <summary>
/// The DropZoneAllProgressEventArgs class provides information for PDDropZone batch progress events.
/// </summary>
public class DropZoneAllProgressEventArgs
{
/// <summary>
/// Gets or sets the progress (0-100).
/// </summary>
public double UploadProgress { get; set; }

/// <summary>
/// Gets or sets the total number of bytes to be sent.
/// </summary>
public long TotalBytes { get; set; }

/// <summary>
/// Gets or sets the total number of bytes sent.
/// </summary>
public long TotalBytesSent { get; set; }
}
153 changes: 0 additions & 153 deletions PanoramicData.Blazor/Arguments/DropZoneEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,156 +41,3 @@ public class DropZoneEventArgs(object sender, DropZoneFile[] files)
/// </summary>
public object? State { get; set; }
}

/// <summary>
/// The DropZoneUploadEventArgs class provides information for PDDropZone upload events.
/// </summary>
/// <remarks>
/// Initializes a new instance of the DropZoneUploadEventArgs class.
/// </remarks>
/// <param name="path">The path where the file is being uploaded.</param>
/// <param name="name">The name of the file being uploaded.</param>
/// <param name="size">The size of the file being uploaded.</param>
/// <param name="key">Unique key for upload.</param>
/// <param name="sessionId">Unique identifier for the session.</param>
public class DropZoneUploadEventArgs(string path, string name, long size, string key, string sessionId)
{

/// <summary>
/// Gets or sets the path where the file is being uploaded to.
/// </summary>
public string Path { get; set; } = path;

/// <summary>
/// Gets or sets the name of the file being uploaded.
/// </summary>
public string Name { get; set; } = name;

/// <summary>
/// Gets or sets the size of the file being uploaded.
/// </summary>
public long Size { get; set; } = size;

/// <summary>
/// Gets or sets the unique identifier of the file being uploaded.
/// </summary>
public string Key { get; set; } = key;

/// <summary>
/// Gets or sets the unique identifier of the session.
/// </summary>
public string SessionId { get; set; } = sessionId;

/// <summary>
/// Gets or sets additional form fields to be sent with the upload request.
/// </summary>
public Dictionary<string, string> FormFields { get; set; } = [];

/// <summary>
/// Gets or sets the total number of files in the batch.
/// </summary>
public int BatchCount { get; set; }

/// <summary>
/// Gets or sets the current file within the batch being uploaded.
/// </summary>
public int BatchProgress { get; set; }

public string FullPath
{
get
{
return $"{Path.TrimEnd('/')}/{Name.TrimStart('/')}";
}
}
}

/// <summary>
/// The DropZoneUploadProgressEventArgs class provides information for PDDropZone upload events.
/// </summary>
/// <remarks>
/// Initializes a new instance of the DropZoneUploadEventArgs class.
/// </remarks>
/// <param name="path">The path where the file is being uploaded.</param>
/// <param name="name">The name of the file being uploaded.</param>
/// <param name="size">The size of the file being uploaded.</param>
public class DropZoneUploadProgressEventArgs(string path, string name, long size, string key, string sessionId, double progress) : DropZoneUploadEventArgs(path, name, size, key, sessionId)
{

/// <summary>
/// Gets or sets the
/// </summary>
public double Progress { get; set; } = progress;

/// <summary>
/// Gets or sets whether the operation should be cancelled.
/// </summary>
public bool Cancel { get; set; }

/// <summary>
/// Optional string detailing why the operation is to be cancelled.
/// </summary>
public string CancelReason { get; set; } = string.Empty;
}

/// <summary>
/// The DropZoneUploadCompletedEventArgs class provides information for PDDropZone upload completed events.
/// </summary>
public class DropZoneUploadCompletedEventArgs : DropZoneUploadEventArgs
{
/// <summary>
/// Initializes a new instance of the DropZoneUploadCompletedEventArgs class.
/// </summary>
/// <param name="path">The path where the file is being uploaded.</param>
/// <param name="name">The name of the file being uploaded.</param>
/// <param name="size">The size of the file being uploaded.</param>
public DropZoneUploadCompletedEventArgs(string path, string name, long size, string key, string sessionId)
: base(path, name, size, key, sessionId)
{
Success = true;
}

/// <summary>
/// Initializes a new instance of the DropZoneUploadCompletedEventArgs class.
/// </summary>
/// <param name="path">The path where the file is being uploaded.</param>
/// <param name="name">The name of the file being uploaded.</param>
/// <param name="size">The size of the file being uploaded.</param>
/// <param name="reason">Reason for the upload failure.</param>
public DropZoneUploadCompletedEventArgs(string path, string name, long size, string key, string sessionId, string reason)
: base(path, name, size, key, sessionId)
{
Reason = reason;
}

/// <summary>
/// Gets or sets whether the upload was completed successfully or not.
/// </summary>
public bool Success { get; set; }

/// <summary>
/// Gets or sets an optional short message as to why the upload failed.
/// </summary>
public string Reason { get; set; } = string.Empty;
}

/// <summary>
/// The DropZoneAllProgressEventArgs class provides information for PDDropZone batch progress events.
/// </summary>
public class DropZoneAllProgressEventArgs
{
/// <summary>
/// Gets or sets the progress (0-100).
/// </summary>
public double UploadProgress { get; set; }

/// <summary>
/// Gets or sets the total number of bytes to be sent.
/// </summary>
public long TotalBytes { get; set; }

/// <summary>
/// Gets or sets the total number of bytes sent.
/// </summary>
public long TotalBytesSent { get; set; }
}
42 changes: 42 additions & 0 deletions PanoramicData.Blazor/Arguments/DropZoneUploadCompletedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace PanoramicData.Blazor.Arguments;

/// <summary>
/// The DropZoneUploadCompletedEventArgs class provides information for PDDropZone upload completed events.
/// </summary>
public class DropZoneUploadCompletedEventArgs : DropZoneUploadEventArgs
{
/// <summary>
/// Initializes a new instance of the DropZoneUploadCompletedEventArgs class.
/// </summary>
/// <param name="path">The path where the file is being uploaded.</param>
/// <param name="name">The name of the file being uploaded.</param>
/// <param name="size">The size of the file being uploaded.</param>
public DropZoneUploadCompletedEventArgs(string path, string name, long size, string key, string sessionId)
: base(path, name, size, key, sessionId)
{
Success = true;
}

/// <summary>
/// Initializes a new instance of the DropZoneUploadCompletedEventArgs class.
/// </summary>
/// <param name="path">The path where the file is being uploaded.</param>
/// <param name="name">The name of the file being uploaded.</param>
/// <param name="size">The size of the file being uploaded.</param>
/// <param name="reason">Reason for the upload failure.</param>
public DropZoneUploadCompletedEventArgs(string path, string name, long size, string key, string sessionId, string reason)
: base(path, name, size, key, sessionId)
{
Reason = reason;
}

/// <summary>
/// Gets or sets whether the upload was completed successfully or not.
/// </summary>
public bool Success { get; set; }

/// <summary>
/// Gets or sets an optional short message as to why the upload failed.
/// </summary>
public string Reason { get; set; } = string.Empty;
}
64 changes: 64 additions & 0 deletions PanoramicData.Blazor/Arguments/DropZoneUploadEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
namespace PanoramicData.Blazor.Arguments;

/// <summary>
/// The DropZoneUploadEventArgs class provides information for PDDropZone upload events.
/// </summary>
/// <remarks>
/// Initializes a new instance of the DropZoneUploadEventArgs class.
/// </remarks>
/// <param name="path">The path where the file is being uploaded.</param>
/// <param name="name">The name of the file being uploaded.</param>
/// <param name="size">The size of the file being uploaded.</param>
/// <param name="key">Unique key for upload.</param>
/// <param name="sessionId">Unique identifier for the session.</param>
public class DropZoneUploadEventArgs(string path, string name, long size, string key, string sessionId)
{

/// <summary>
/// Gets or sets the path where the file is being uploaded to.
/// </summary>
public string Path { get; set; } = path;

/// <summary>
/// Gets or sets the name of the file being uploaded.
/// </summary>
public string Name { get; set; } = name;

/// <summary>
/// Gets or sets the size of the file being uploaded.
/// </summary>
public long Size { get; set; } = size;

/// <summary>
/// Gets or sets the unique identifier of the file being uploaded.
/// </summary>
public string Key { get; set; } = key;

/// <summary>
/// Gets or sets the unique identifier of the session.
/// </summary>
public string SessionId { get; set; } = sessionId;

/// <summary>
/// Gets or sets additional form fields to be sent with the upload request.
/// </summary>
public Dictionary<string, string> FormFields { get; set; } = [];

/// <summary>
/// Gets or sets the total number of files in the batch.
/// </summary>
public int BatchCount { get; set; }

/// <summary>
/// Gets or sets the current file within the batch being uploaded.
/// </summary>
public int BatchProgress { get; set; }

public string FullPath
{
get
{
return $"{Path.TrimEnd('/')}/{Name.TrimStart('/')}";
}
}
}
29 changes: 29 additions & 0 deletions PanoramicData.Blazor/Arguments/DropZoneUploadProgressEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace PanoramicData.Blazor.Arguments;

/// <summary>
/// The DropZoneUploadProgressEventArgs class provides information for PDDropZone upload events.
/// </summary>
/// <remarks>
/// Initializes a new instance of the DropZoneUploadEventArgs class.
/// </remarks>
/// <param name="path">The path where the file is being uploaded.</param>
/// <param name="name">The name of the file being uploaded.</param>
/// <param name="size">The size of the file being uploaded.</param>
public class DropZoneUploadProgressEventArgs(string path, string name, long size, string key, string sessionId, double progress) : DropZoneUploadEventArgs(path, name, size, key, sessionId)
{

/// <summary>
/// Gets or sets the
/// </summary>
public double Progress { get; set; } = progress;

/// <summary>
/// Gets or sets whether the operation should be cancelled.
/// </summary>
public bool Cancel { get; set; }

/// <summary>
/// Optional string detailing why the operation is to be cancelled.
/// </summary>
public string CancelReason { get; set; } = string.Empty;
}
21 changes: 21 additions & 0 deletions PanoramicData.Blazor/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage(
"Naming",
"CA1711:Identifiers should not have incorrect suffix",
Justification = "Project policy",
Scope = "namespaceanddescendants",
Target = "~N:PanoramicData.Blazor"
)]
[assembly: SuppressMessage(
"Performance",
"CA1848:Use the LoggerMessage delegates",
Justification = "Performance gain not worth the effort",
Scope = "namespaceanddescendants",
Target = "~N:PanoramicData.Blazor"
)]
8 changes: 4 additions & 4 deletions PanoramicData.Blazor/PDMonacoEditor.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,24 @@ private StandaloneEditorConstructionOptions GetOptions(StandaloneCodeEditor edit
return options;
}

public async Task<string> GetMonacoValueAsync(EndOfLinePreference eol, bool preserveBOM)
public async Task<string> GetMonacoValueAsync(EndOfLinePreference endOfLinePreference, bool preserveBOM)
{
if (_monacoEditor != null)
{
var model = await _monacoEditor.GetModel();
var value = await model.GetValue(eol, preserveBOM);
var value = await model.GetValue(endOfLinePreference, preserveBOM);
return value;
}

return string.Empty;
}

public async Task<string> GetMonacoValueAsync(Range range, EndOfLinePreference eol)
public async Task<string> GetMonacoValueAsync(Range range, EndOfLinePreference endOfLinePreference)
{
if (_monacoEditor != null)
{
var model = await _monacoEditor.GetModel();
var value = await model.GetValueInRange(range, eol);
var value = await model.GetValueInRange(range, endOfLinePreference);
return value;
}

Expand Down
Loading

0 comments on commit 1f15e22

Please sign in to comment.