mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
I (Jason Shirk) ran https://github.com/dotnet/codeformatter with the default rules, basically: codeformatter /nocopyright "/c:DEBUG,UNIX,CORECLR" @files.rsp This caused a few problems building, which were fixed up manually. Notable changes: `this.` is removed unless needed to disambiguate. private instance fields are renamed to have a `_` prefix. private static fields are renamed to have a `s_` prefix. I left some projects alone (like PackageManagement) and also left some generated code alone.
76 lines
1.7 KiB
C#
76 lines
1.7 KiB
C#
//
|
|
// Copyright (C) Microsoft. All rights reserved.
|
|
//
|
|
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Runtime.ConstrainedExecution;
|
|
|
|
namespace Microsoft.Powershell.Commands.GetCounter.PdhNative
|
|
{
|
|
internal sealed class PdhSafeDataSourceHandle : SafeHandle
|
|
{
|
|
private PdhSafeDataSourceHandle() : base(IntPtr.Zero, true) { }
|
|
|
|
public override bool IsInvalid
|
|
{
|
|
get
|
|
{
|
|
return handle == IntPtr.Zero;
|
|
}
|
|
}
|
|
|
|
|
|
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
|
protected override bool ReleaseHandle()
|
|
{
|
|
return (PdhHelper.PdhCloseLog(handle, 0) == 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
internal sealed class PdhSafeQueryHandle : SafeHandle
|
|
{
|
|
private PdhSafeQueryHandle() : base(IntPtr.Zero, true) { }
|
|
|
|
public override bool IsInvalid
|
|
{
|
|
get
|
|
{
|
|
return handle == IntPtr.Zero;
|
|
}
|
|
}
|
|
|
|
|
|
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
|
protected override bool ReleaseHandle()
|
|
{
|
|
return (PdhHelper.PdhCloseQuery(handle) == 0);
|
|
}
|
|
}
|
|
|
|
internal sealed class PdhSafeLogHandle : SafeHandle
|
|
{
|
|
private PdhSafeLogHandle() : base(IntPtr.Zero, true) { }
|
|
|
|
public override bool IsInvalid
|
|
{
|
|
get
|
|
{
|
|
return handle == IntPtr.Zero;
|
|
}
|
|
}
|
|
|
|
|
|
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
|
protected override bool ReleaseHandle()
|
|
{
|
|
return (PdhHelper.PdhCloseLog(handle, 0) == 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
|