Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- graph.cs
- FlowDocumentScrollViewer.cs
- ColorPalette.cs
- GridView.cs
- CurrencyWrapper.cs
- GenericWebPart.cs
- QueryServiceConfigHandle.cs
- HttpStreamXmlDictionaryReader.cs
- MsmqIntegrationValidationBehavior.cs
- mediaclock.cs
- IERequestCache.cs
- DiagnosticsConfiguration.cs
- basenumberconverter.cs
- XPathSelectionIterator.cs
- Vector3DCollectionConverter.cs
- Point3DCollection.cs
- Matrix.cs
- DataTableCollection.cs
- LinkClickEvent.cs
- CorrelationManager.cs
- ScalarType.cs
- EventListenerClientSide.cs
- SiteMapNode.cs
- SortedList.cs
- WebPartConnectVerb.cs
- IgnoreDeviceFilterElementCollection.cs
- IntSecurity.cs
- Configuration.cs
- ExpandSegment.cs
- ReachFixedDocumentSerializer.cs
- DataGridColumnHeadersPresenter.cs
- BitmapImage.cs
- unitconverter.cs
- RewritingProcessor.cs
- RSATokenProvider.cs
- EntityProxyFactory.cs
- ValidationResult.cs
- MethodBuilderInstantiation.cs
- Int32CollectionValueSerializer.cs
- ViewGenResults.cs
- EventSetterHandlerConverter.cs
- CachedCompositeFamily.cs
- XmlSerializationGeneratedCode.cs
- LinkedResource.cs
- DataStreams.cs
- SqlStream.cs
- ConstructorNeedsTagAttribute.cs
- ModifiableIteratorCollection.cs
- VariableAction.cs
- UInt64Storage.cs
- HttpBrowserCapabilitiesWrapper.cs
- DesignRelationCollection.cs
- ActiveDocumentEvent.cs
- WarningException.cs
- ScrollChrome.cs
- X509Extension.cs
- ClockController.cs
- SqlException.cs
- HttpInputStream.cs
- Journaling.cs
- SchemaImporterExtensionElement.cs
- NoneExcludedImageIndexConverter.cs
- XPathDescendantIterator.cs
- ContentElement.cs
- _RequestCacheProtocol.cs
- CharacterHit.cs
- AssemblyResolver.cs
- XmlAnyAttributeAttribute.cs
- StatusBar.cs
- DateTimeOffsetStorage.cs
- ViewLoader.cs
- TimeSpanValidatorAttribute.cs
- MaskedTextBoxDesignerActionList.cs
- InternalBase.cs
- AsymmetricAlgorithm.cs
- XamlSerializerUtil.cs
- RtType.cs
- HyperLinkStyle.cs
- OneWayElement.cs
- CodeObject.cs
- PackageDigitalSignature.cs
- TableRow.cs
- ScriptManager.cs
- DataBoundControlHelper.cs
- IndependentAnimationStorage.cs
- SmtpLoginAuthenticationModule.cs
- HTMLTextWriter.cs
- DecimalAnimation.cs
- XmlStringTable.cs
- XmlUtil.cs
- SecUtil.cs
- FormViewUpdatedEventArgs.cs
- basenumberconverter.cs
- MasterPage.cs
- BinaryReader.cs
- SamlSubjectStatement.cs
- MappableObjectManager.cs
- ReflectionUtil.cs
- DataGridPagerStyle.cs
- CollectionViewSource.cs