Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / DataOracleClient / System / Data / OracleClient / OciEnlistContext.cs / 1 / OciEnlistContext.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Data.OracleClient
{
using System;
using System.Data.Common;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using SysTx = System.Transactions;
using System.Runtime.ConstrainedExecution;
sealed internal class OciEnlistContext : SafeHandle {
private OciServiceContextHandle _serviceContextHandle;
internal OciEnlistContext(byte[] userName, byte[] password, byte[] serverName, OciServiceContextHandle serviceContextHandle, OciErrorHandle errorHandle) : base(IntPtr.Zero, true) {
RuntimeHelpers.PrepareConstrainedRegions();
try {} finally {
_serviceContextHandle = serviceContextHandle;
int rc = 0;
try {
rc = TracedNativeMethods.OraMTSEnlCtxGet(userName, password, serverName, _serviceContextHandle, errorHandle, out base.handle);
}
catch (DllNotFoundException e) {
throw ADP.DistribTxRequiresOracleServicesForMTS(e);
}
if (0 != rc) {
OracleException.Check(errorHandle, rc);
}
// Make sure the transaction context is disposed before the service
// context is.
serviceContextHandle.AddRef();
}
}
public override bool IsInvalid {
get {
return (IntPtr.Zero == base.handle);
}
}
internal void Join(OracleInternalConnection internalConnection, SysTx.Transaction indigoTransaction) {
SysTx.IDtcTransaction oleTxTransaction = ADP.GetOletxTransaction(indigoTransaction);
int rc = TracedNativeMethods.OraMTSJoinTxn(this, oleTxTransaction);
if (0 != rc) {
OracleException.Check(rc, internalConnection);
}
}
override protected bool ReleaseHandle() {
// NOTE: The SafeHandle class guarantees this will be called exactly once.
IntPtr ptr = base.handle;
base.handle = IntPtr.Zero;
if (IntPtr.Zero != ptr) {
TracedNativeMethods.OraMTSEnlCtxRel(ptr);
}
// OK, now we can release the service context.
if (null != _serviceContextHandle) {
_serviceContextHandle.Release();
_serviceContextHandle = null;
}
return true;
}
internal static void SafeDispose(ref OciEnlistContext ociEnlistContext) {
// Safely disposes of the handle (even if it is already null) and
// then nulls it out.
if (null != ociEnlistContext) {
ociEnlistContext.Dispose();
}
ociEnlistContext = null;
}
//---------------------------------------------------------------------
static internal IntPtr HandleValueToTrace (OciEnlistContext handle)
{
return handle.DangerousGetHandle(); // for tracing purposes, it's safe to just print this -- no handle recycling issues.
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Data.OracleClient
{
using System;
using System.Data.Common;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using SysTx = System.Transactions;
using System.Runtime.ConstrainedExecution;
sealed internal class OciEnlistContext : SafeHandle {
private OciServiceContextHandle _serviceContextHandle;
internal OciEnlistContext(byte[] userName, byte[] password, byte[] serverName, OciServiceContextHandle serviceContextHandle, OciErrorHandle errorHandle) : base(IntPtr.Zero, true) {
RuntimeHelpers.PrepareConstrainedRegions();
try {} finally {
_serviceContextHandle = serviceContextHandle;
int rc = 0;
try {
rc = TracedNativeMethods.OraMTSEnlCtxGet(userName, password, serverName, _serviceContextHandle, errorHandle, out base.handle);
}
catch (DllNotFoundException e) {
throw ADP.DistribTxRequiresOracleServicesForMTS(e);
}
if (0 != rc) {
OracleException.Check(errorHandle, rc);
}
// Make sure the transaction context is disposed before the service
// context is.
serviceContextHandle.AddRef();
}
}
public override bool IsInvalid {
get {
return (IntPtr.Zero == base.handle);
}
}
internal void Join(OracleInternalConnection internalConnection, SysTx.Transaction indigoTransaction) {
SysTx.IDtcTransaction oleTxTransaction = ADP.GetOletxTransaction(indigoTransaction);
int rc = TracedNativeMethods.OraMTSJoinTxn(this, oleTxTransaction);
if (0 != rc) {
OracleException.Check(rc, internalConnection);
}
}
override protected bool ReleaseHandle() {
// NOTE: The SafeHandle class guarantees this will be called exactly once.
IntPtr ptr = base.handle;
base.handle = IntPtr.Zero;
if (IntPtr.Zero != ptr) {
TracedNativeMethods.OraMTSEnlCtxRel(ptr);
}
// OK, now we can release the service context.
if (null != _serviceContextHandle) {
_serviceContextHandle.Release();
_serviceContextHandle = null;
}
return true;
}
internal static void SafeDispose(ref OciEnlistContext ociEnlistContext) {
// Safely disposes of the handle (even if it is already null) and
// then nulls it out.
if (null != ociEnlistContext) {
ociEnlistContext.Dispose();
}
ociEnlistContext = null;
}
//---------------------------------------------------------------------
static internal IntPtr HandleValueToTrace (OciEnlistContext handle)
{
return handle.DangerousGetHandle(); // for tracing purposes, it's safe to just print this -- no handle recycling issues.
}
}
}
// 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
- HtmlButton.cs
- EndpointAddress.cs
- AppDomainAttributes.cs
- HtmlInputReset.cs
- RectangleGeometry.cs
- ViewCellRelation.cs
- WebBrowserPermission.cs
- InternalCache.cs
- DesignTimeParseData.cs
- ComplexTypeEmitter.cs
- DescendantBaseQuery.cs
- DataSysAttribute.cs
- ValidateNames.cs
- BaseComponentEditor.cs
- ScrollPattern.cs
- CfgParser.cs
- HostedController.cs
- IncrementalCompileAnalyzer.cs
- ExtensionFile.cs
- ControlBuilder.cs
- CompilerWrapper.cs
- Invariant.cs
- MultiAsyncResult.cs
- Model3DCollection.cs
- MaskedTextBox.cs
- grammarelement.cs
- SelectionItemProviderWrapper.cs
- DeadCharTextComposition.cs
- cache.cs
- SharedUtils.cs
- BooleanFunctions.cs
- PassportAuthenticationEventArgs.cs
- PathFigureCollectionConverter.cs
- GroupItem.cs
- EventProvider.cs
- DiscoveryDocumentSearchPattern.cs
- FormParameter.cs
- ComNativeDescriptor.cs
- Char.cs
- InfoCardTrace.cs
- ChannelManager.cs
- FormViewDeletedEventArgs.cs
- RequestResizeEvent.cs
- UInt32Converter.cs
- SortDescriptionCollection.cs
- OdbcReferenceCollection.cs
- ImageSourceConverter.cs
- SelectionHighlightInfo.cs
- GifBitmapDecoder.cs
- EntityDataSourceStatementEditorForm.cs
- CodePrimitiveExpression.cs
- EncoderParameter.cs
- SqlEnums.cs
- QfeChecker.cs
- QilFactory.cs
- AppDomainEvidenceFactory.cs
- SR.cs
- CodeDelegateInvokeExpression.cs
- StringAnimationUsingKeyFrames.cs
- DataControlField.cs
- DrawingContext.cs
- TraceData.cs
- FastEncoder.cs
- PageAsyncTaskManager.cs
- CodeDirectionExpression.cs
- MetafileHeader.cs
- Compensate.cs
- ToolboxItem.cs
- BlurBitmapEffect.cs
- AdapterUtil.cs
- PagesSection.cs
- exports.cs
- PriorityQueue.cs
- PresentationAppDomainManager.cs
- HtmlAnchor.cs
- CompilerCollection.cs
- TrustLevelCollection.cs
- ServiceCredentialsElement.cs
- DataReaderContainer.cs
- FileStream.cs
- ExpressionTextBox.xaml.cs
- LayoutEngine.cs
- XPathBinder.cs
- StylusShape.cs
- NetTcpBindingCollectionElement.cs
- XpsSerializationException.cs
- embossbitmapeffect.cs
- DbParameterHelper.cs
- ValidatedControlConverter.cs
- ComPlusInstanceContextInitializer.cs
- IpcPort.cs
- KeySplineConverter.cs
- ReflectEventDescriptor.cs
- Path.cs
- CompilationRelaxations.cs
- WebPartsPersonalizationAuthorization.cs
- DuplexClientBase.cs
- Operand.cs
- DateTimeConverter.cs
- DesignerCategoryAttribute.cs