internal int Release()
        {
            int num2;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
            }
            finally
            {
                int num;
                num2 = Interlocked.Decrement(ref this._refCount);
                if (num2 != 0)
                {
                    goto Label_0168;
                }
                IntPtr hndlp = Interlocked.CompareExchange(ref this.handle, IntPtr.Zero, base.handle);
                if (!(IntPtr.Zero != hndlp))
                {
                    goto Label_0168;
                }
                OCI.HTYPE handleType   = this.HandleType;
                OciHandle parentHandle = this.ParentHandle;
                switch (handleType)
                {
                case OCI.HTYPE.OCI_HTYPE_ENV:
                    num = TracedNativeMethods.OCIHandleFree(hndlp, handleType);
                    if (num != 0)
                    {
                        throw System.Data.Common.ADP.OperationFailed("OCIHandleFree", num);
                    }
                    goto Label_015E;

                case OCI.HTYPE.OCI_HTYPE_ERROR:
                case OCI.HTYPE.OCI_HTYPE_STMT:
                case OCI.HTYPE.OCI_HTYPE_SESSION:
                    break;

                case OCI.HTYPE.OCI_HTYPE_SVCCTX:
                {
                    OciHandle handle2 = parentHandle;
                    if (handle2 != null)
                    {
                        OciHandle handle4 = handle2.ParentHandle;
                        if (handle4 != null)
                        {
                            OciHandle handle3 = handle4.ParentHandle;
                            if (handle3 != null)
                            {
                                num = TracedNativeMethods.OCISessionEnd(hndlp, handle3.DangerousGetHandle(), handle2.DangerousGetHandle(), OCI.MODE.OCI_DEFAULT);
                            }
                        }
                    }
                    break;
                }

                case OCI.HTYPE.OCI_HTYPE_SERVER:
                    TracedNativeMethods.OCIServerDetach(hndlp, parentHandle.DangerousGetHandle(), OCI.MODE.OCI_DEFAULT);
                    break;

                case OCI.HTYPE.OCI_DTYPE_FIRST:
                case OCI.HTYPE.OCI_DTYPE_ROWID:
                case OCI.HTYPE.OCI_DTYPE_FILE:
                case OCI.HTYPE.OCI_DTYPE_INTERVAL_DS:
                case OCI.HTYPE.OCI_DTYPE_TIMESTAMP:
                case OCI.HTYPE.OCI_DTYPE_TIMESTAMP_TZ:
                case OCI.HTYPE.OCI_DTYPE_TIMESTAMP_LTZ:
                    num = TracedNativeMethods.OCIDescriptorFree(hndlp, handleType);
                    if (num != 0)
                    {
                        throw System.Data.Common.ADP.OperationFailed("OCIDescriptorFree", num);
                    }
                    goto Label_015E;

                default:
                    goto Label_015E;
                }
                num = TracedNativeMethods.OCIHandleFree(hndlp, handleType);
                if (num != 0)
                {
                    throw System.Data.Common.ADP.OperationFailed("OCIHandleFree", num);
                }
Label_015E:
                if (parentHandle != null)
                {
                    parentHandle.Release();
                }
                Label_0168 :;
            }
            return(num2);
        }