Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Diagnostics / Eventing / Reader / EventLogHandle.cs / 1305376 / EventLogHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: EventLogHandle ** ** Purpose: ** This internal class is a SafeHandle implementation over a ** native EVT_HANDLE - obtained from EventLog Native Methods. ** ============================================================*/ using System; using System.Runtime.InteropServices; using System.Security.Permissions; namespace System.Diagnostics.Eventing.Reader { // // Marked as SecurityCritical due to link demands from inherited // SafeHandle members. // // marked as Safe since the only real operation that is performed // by this class is NativeWrapper.EvtClose and that is protected // by a full Demand() before doing any work. [System.Security.SecuritySafeCritical] internal sealed class EventLogHandle : SafeHandle { // Called by P/Invoke when returning SafeHandles private EventLogHandle() : base(IntPtr.Zero, true) { } internal EventLogHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { SetHandle(handle); } public override bool IsInvalid { get { return IsClosed || handle == IntPtr.Zero; } } protected override bool ReleaseHandle() { NativeWrapper.EvtClose(handle); handle = IntPtr.Zero; return true; } // DONT compare EventLogHandle with EventLogHandle.Zero // use IsInvalid instead. Zero is provided where a NULL handle needed public static EventLogHandle Zero { get { return new EventLogHandle(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: EventLogHandle ** ** Purpose: ** This internal class is a SafeHandle implementation over a ** native EVT_HANDLE - obtained from EventLog Native Methods. ** ============================================================*/ using System; using System.Runtime.InteropServices; using System.Security.Permissions; namespace System.Diagnostics.Eventing.Reader { // // Marked as SecurityCritical due to link demands from inherited // SafeHandle members. // // marked as Safe since the only real operation that is performed // by this class is NativeWrapper.EvtClose and that is protected // by a full Demand() before doing any work. [System.Security.SecuritySafeCritical] internal sealed class EventLogHandle : SafeHandle { // Called by P/Invoke when returning SafeHandles private EventLogHandle() : base(IntPtr.Zero, true) { } internal EventLogHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { SetHandle(handle); } public override bool IsInvalid { get { return IsClosed || handle == IntPtr.Zero; } } protected override bool ReleaseHandle() { NativeWrapper.EvtClose(handle); handle = IntPtr.Zero; return true; } // DONT compare EventLogHandle with EventLogHandle.Zero // use IsInvalid instead. Zero is provided where a NULL handle needed public static EventLogHandle Zero { get { return new EventLogHandle(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ConfigXmlElement.cs
- MD5.cs
- UniqueContractNameValidationBehavior.cs
- ByteStorage.cs
- ArcSegment.cs
- MetadataFile.cs
- EventLog.cs
- ScrollViewerAutomationPeer.cs
- FormParameter.cs
- FSWPathEditor.cs
- _SslState.cs
- FieldToken.cs
- SectionInput.cs
- ParameterModifier.cs
- PageParser.cs
- dataprotectionpermission.cs
- ProcessModule.cs
- ErrorFormatterPage.cs
- Variable.cs
- Tool.cs
- XamlSerializer.cs
- CollectionViewSource.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- UnknownExceptionActionHelper.cs
- DbLambda.cs
- InboundActivityHelper.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- TdsEnums.cs
- StorageConditionPropertyMapping.cs
- UriGenerator.cs
- TreeChangeInfo.cs
- ListViewItem.cs
- DataGridTextBox.cs
- Crc32Helper.cs
- DefaultCommandExtensionCallback.cs
- PrinterResolution.cs
- EventTrigger.cs
- InstanceKeyView.cs
- QueryIntervalOp.cs
- XmlReflectionMember.cs
- MessageQueueAccessControlEntry.cs
- InstanceHandleReference.cs
- PropertyPathWorker.cs
- WebPartVerbsEventArgs.cs
- WebReferencesBuildProvider.cs
- ValueConversionAttribute.cs
- ImageIndexConverter.cs
- AdCreatedEventArgs.cs
- MatrixTransform.cs
- Binding.cs
- StorageTypeMapping.cs
- BindStream.cs
- Error.cs
- ComponentRenameEvent.cs
- ActiveXHelper.cs
- DetailsViewInsertedEventArgs.cs
- Message.cs
- DetailsViewPageEventArgs.cs
- BufferBuilder.cs
- MouseEvent.cs
- ItemAutomationPeer.cs
- CatalogPartCollection.cs
- BoolExpressionVisitors.cs
- DetailsViewCommandEventArgs.cs
- Type.cs
- HttpHandlerActionCollection.cs
- RenameRuleObjectDialog.Designer.cs
- FlowLayout.cs
- StylusPointDescription.cs
- MergeFilterQuery.cs
- SortedList.cs
- OneOfElement.cs
- _LoggingObject.cs
- ProfessionalColorTable.cs
- HwndProxyElementProvider.cs
- WindowsButton.cs
- FreezableOperations.cs
- ImageCodecInfo.cs
- Baml6ConstructorInfo.cs
- ConversionHelper.cs
- ByteFacetDescriptionElement.cs
- NamedObject.cs
- Operand.cs
- FixedSOMGroup.cs
- SubstitutionList.cs
- BufferedStream.cs
- StringStorage.cs
- X509ThumbprintKeyIdentifierClause.cs
- ComponentEditorForm.cs
- EdmItemCollection.cs
- ExtensibleClassFactory.cs
- Frame.cs
- ReadWriteControlDesigner.cs
- FontSource.cs
- AlternateViewCollection.cs
- Selection.cs
- NotifyIcon.cs
- CommonDialog.cs
- X509RecipientCertificateServiceElement.cs
- WebPartMinimizeVerb.cs