Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / UIAutomationClient / MS / Internal / Automation / SafeHandles.cs / 1305600 / SafeHandles.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: Various SafeHandles used by UIA
//
//---------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using System.Windows.Automation;
using System.Windows.Automation.Provider;
// PRESHARP: In order to avoid generating warnings about unkown message numbers and unknown pragmas.
#pragma warning disable 1634, 1691
namespace MS.Internal.Automation
{
internal sealed class SafeNodeHandle : SafeHandle
{
// Called by P/Invoke when returning SafeHandles
// (Also used by UiaCoreApi to create invalid handles.)
internal SafeNodeHandle()
: base(IntPtr.Zero, true)
{
}
// No need to provide a finalizer - SafeHandle's critical finalizer will
// call ReleaseHandle for you.
public override bool IsInvalid
{
get { return handle == IntPtr.Zero; }
}
override protected bool ReleaseHandle()
{
return UiaCoreApi.UiaNodeRelease(handle);
}
}
// Internal Class that wraps the IntPtr to the Pattern
internal sealed class SafePatternHandle : SafeHandle
{
// Called by P/Invoke when returning SafeHandles
// (Also used by UiaCoreApi to create invalid handles.)
internal SafePatternHandle()
: base(IntPtr.Zero, true)
{
}
// No need to provide a finalizer - SafeHandle's critical finalizer will
// call ReleaseHandle for you.
public override bool IsInvalid
{
get { return handle == IntPtr.Zero; }
}
override protected bool ReleaseHandle()
{
return UiaCoreApi.UiaPatternRelease(handle);
}
}
// Internal Class that wraps the IntPtr to the Event
internal sealed class SafeEventHandle : SafeHandle
{
internal SafeEventHandle()
: base(IntPtr.Zero, true)
{
}
public override bool IsInvalid
{
get { return handle == IntPtr.Zero; }
}
override protected bool ReleaseHandle()
{
UiaCoreApi.UiaRemoveEvent(handle);
return true;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SemaphoreFullException.cs
- HttpStreamMessageEncoderFactory.cs
- HttpModuleCollection.cs
- AssemblyGen.cs
- TextServicesCompartmentEventSink.cs
- AlphabeticalEnumConverter.cs
- PriorityQueue.cs
- CodeTypeDeclarationCollection.cs
- FileSystemWatcher.cs
- PointAnimation.cs
- StylusPointProperties.cs
- RichTextBox.cs
- ColumnCollection.cs
- SmiContextFactory.cs
- ProfileService.cs
- Thickness.cs
- FocusTracker.cs
- PrintDocument.cs
- _emptywebproxy.cs
- BitVector32.cs
- SizeKeyFrameCollection.cs
- LoginView.cs
- ConfigXmlCDataSection.cs
- SqlMethodTransformer.cs
- SortQuery.cs
- ConstructorBuilder.cs
- NamedElement.cs
- RegisteredHiddenField.cs
- EditorAttribute.cs
- Condition.cs
- DocumentSchemaValidator.cs
- RelationshipWrapper.cs
- ForceCopyBuildProvider.cs
- TextEndOfSegment.cs
- GiveFeedbackEventArgs.cs
- BasePropertyDescriptor.cs
- IIS7ConfigurationLoader.cs
- safelink.cs
- GraphicsPathIterator.cs
- EntityProviderServices.cs
- Color.cs
- SchemaImporterExtensionsSection.cs
- JsonObjectDataContract.cs
- InstanceBehavior.cs
- ReadOnlyAttribute.cs
- RouteValueDictionary.cs
- Geometry3D.cs
- FormView.cs
- LinkedResourceCollection.cs
- DataRecordInternal.cs
- FontFaceLayoutInfo.cs
- UIntPtr.cs
- ClassicBorderDecorator.cs
- Perspective.cs
- GroupJoinQueryOperator.cs
- ManagementOperationWatcher.cs
- SQLInt32Storage.cs
- ListSortDescription.cs
- TimeSpanOrInfiniteConverter.cs
- MSAAEventDispatcher.cs
- TextRunCacheImp.cs
- DynamicEntity.cs
- ProxyWebPartConnectionCollection.cs
- SuppressMergeCheckAttribute.cs
- TypeDescriptionProviderAttribute.cs
- DesigntimeLicenseContextSerializer.cs
- QilExpression.cs
- RoleService.cs
- ScrollData.cs
- EntityDataSourceStatementEditor.cs
- KeyConverter.cs
- Compensate.cs
- AuthorizationSection.cs
- DescendentsWalker.cs
- figurelength.cs
- ISessionStateStore.cs
- _UriSyntax.cs
- SwitchAttribute.cs
- DataGridItemEventArgs.cs
- ConstraintConverter.cs
- SortKey.cs
- ResourceReferenceKeyNotFoundException.cs
- RectKeyFrameCollection.cs
- Trace.cs
- XmlWriter.cs
- Calendar.cs
- DataGridViewDataConnection.cs
- XmlSchemaType.cs
- TypeUnloadedException.cs
- DiagnosticTraceSource.cs
- InvokeHandlers.cs
- XmlDataSourceNodeDescriptor.cs
- DataFieldConverter.cs
- SqlAliaser.cs
- AccessKeyManager.cs
- MessageDecoder.cs
- XPathAncestorIterator.cs
- PreloadedPackages.cs
- PaperSize.cs
- UpdateCommand.cs