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
- SHA512CryptoServiceProvider.cs
- AttributeAction.cs
- MeasureItemEvent.cs
- XPathNodeList.cs
- ValidationSummary.cs
- RemoteHelper.cs
- DecimalAnimation.cs
- SafeLocalMemHandle.cs
- DataGridRelationshipRow.cs
- DataGridRowEventArgs.cs
- Vector3DAnimationBase.cs
- InputScopeAttribute.cs
- ContentPlaceHolder.cs
- _emptywebproxy.cs
- MdImport.cs
- UrlMappingsSection.cs
- BuildProviderCollection.cs
- WebPartTransformer.cs
- Utilities.cs
- AspCompat.cs
- NavigationWindow.cs
- ResponseStream.cs
- SectionVisual.cs
- XamlToRtfParser.cs
- OleDbPropertySetGuid.cs
- FrameworkElementFactoryMarkupObject.cs
- LogEntryHeaderv1Deserializer.cs
- SocketStream.cs
- SystemIcmpV6Statistics.cs
- WebPartDisplayModeCollection.cs
- AuthenticationServiceManager.cs
- OracleInternalConnection.cs
- ManagementNamedValueCollection.cs
- PeerEndPoint.cs
- OdbcCommand.cs
- MenuBase.cs
- prompt.cs
- ToolStripGripRenderEventArgs.cs
- DesignerSerializationManager.cs
- HostProtectionPermission.cs
- HyperLinkStyle.cs
- Binding.cs
- ImageSource.cs
- Directory.cs
- nulltextnavigator.cs
- ConditionCollection.cs
- DictionarySectionHandler.cs
- CompositeScriptReference.cs
- Page.cs
- FixedSOMPage.cs
- GenericAuthenticationEventArgs.cs
- PropertySourceInfo.cs
- HtmlWindow.cs
- IChannel.cs
- SortedDictionary.cs
- IISMapPath.cs
- IntegerValidatorAttribute.cs
- DataGridViewRowHeaderCell.cs
- QfeChecker.cs
- Compiler.cs
- PropertyGridEditorPart.cs
- Select.cs
- WorkflowTimerService.cs
- DesignerVerb.cs
- SoapEnvelopeProcessingElement.cs
- UdpUtility.cs
- InitializerFacet.cs
- DelegatedStream.cs
- X509AudioLogo.cs
- EventManager.cs
- WorkflowInstance.cs
- OutputWindow.cs
- TextElementEnumerator.cs
- UidManager.cs
- DataListItemCollection.cs
- RegionIterator.cs
- EventEntry.cs
- Keywords.cs
- SpeakCompletedEventArgs.cs
- tibetanshape.cs
- SQLUtility.cs
- SqlGatherProducedAliases.cs
- ResourceReader.cs
- XmlMtomReader.cs
- OracleTransaction.cs
- AccessedThroughPropertyAttribute.cs
- GlobalEventManager.cs
- EntryIndex.cs
- ExceptionHandlers.cs
- EntitySqlQueryBuilder.cs
- NumberFormatInfo.cs
- translator.cs
- SmiGettersStream.cs
- ZipIORawDataFileBlock.cs
- Monitor.cs
- TypeUtil.cs
- initElementDictionary.cs
- XmlRawWriterWrapper.cs
- MSAAEventDispatcher.cs
- DbConnectionPoolGroupProviderInfo.cs