mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Implement IDisposable for ConvertToJsonCommand (#15787)
This commit is contained in:
+24
-1
@@ -16,7 +16,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// This command converts an object to a Json string representation.
|
||||
/// </summary>
|
||||
[Cmdlet(VerbsData.ConvertTo, "Json", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=2096925", RemotingCapability = RemotingCapability.None)]
|
||||
public class ConvertToJsonCommand : PSCmdlet
|
||||
public class ConvertToJsonCommand : PSCmdlet, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the InputObject property.
|
||||
@@ -77,6 +77,29 @@ namespace Microsoft.PowerShell.Commands
|
||||
[Parameter]
|
||||
public StringEscapeHandling EscapeHandling { get; set; } = StringEscapeHandling.Default;
|
||||
|
||||
/// <summary>
|
||||
/// IDisposable implementation, dispose of any disposable resources created by the cmdlet.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of IDisposable for both manual Dispose() and finalizer-called disposal of resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing">
|
||||
/// Specified as true when Dispose() was called, false if this is called from the finalizer.
|
||||
/// </param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_cancellationSource.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prerequisite checks.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user