OracleEncoding.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / DataOracleClient / System / Data / OracleClient / OracleEncoding.cs / 1 / OracleEncoding.cs

                            //------------------------------------------------------------------------------ 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// [....] 
//-----------------------------------------------------------------------------
 
namespace System.Data.OracleClient 
{
    using System; 
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    using System.Text;
 
    //---------------------------------------------------------------------
    // OracleEncoding 
    // 
    //  Implements an Encoding Scheme that works with Oracle's conversions
    //  for the database character set. 
    //
    sealed internal class OracleEncoding : Encoding {
        OracleInternalConnection _connection;
 
        internal OciHandle Handle {
            get { 
                OciHandle   ociHandle = _connection.SessionHandle; 

                if (null == ociHandle || ociHandle.IsInvalid) { 
                    ociHandle = _connection.EnvironmentHandle;
                }
                return ociHandle;
            } 
        }
 
        public OracleEncoding(OracleInternalConnection connection) : base() { 
            _connection = connection;
        } 

        public override int GetByteCount(char[] chars, int index, int count) {
            int byteCount = GetBytes(chars, index, count, null, 0);
            return byteCount; 
        }
 
        public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { 
            OciHandle   ociHandle = Handle;
            int         byteCount = checked((int)ociHandle.GetBytes(chars, charIndex, unchecked((uint)charCount), bytes, byteIndex)); 
            return byteCount;
        }

        public override int GetCharCount(byte[] bytes, int index, int count) { 
            int charCount = GetChars(bytes, index, count, null, 0);
            return charCount; 
        } 

        public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { 
            OciHandle   ociHandle = Handle;
            int         charCount = checked((int)ociHandle.GetChars(bytes, byteIndex, unchecked((uint)byteCount), chars, charIndex));
            return charCount;
        } 

        public override int GetMaxByteCount(int charCount) { 
            return checked (charCount * 4); 
        }
 
        public override int GetMaxCharCount(int byteCount) {
            return byteCount;
        }
    } 
}
 

// 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.Diagnostics;
    using System.Runtime.InteropServices;
    using System.Text;
 
    //---------------------------------------------------------------------
    // OracleEncoding 
    // 
    //  Implements an Encoding Scheme that works with Oracle's conversions
    //  for the database character set. 
    //
    sealed internal class OracleEncoding : Encoding {
        OracleInternalConnection _connection;
 
        internal OciHandle Handle {
            get { 
                OciHandle   ociHandle = _connection.SessionHandle; 

                if (null == ociHandle || ociHandle.IsInvalid) { 
                    ociHandle = _connection.EnvironmentHandle;
                }
                return ociHandle;
            } 
        }
 
        public OracleEncoding(OracleInternalConnection connection) : base() { 
            _connection = connection;
        } 

        public override int GetByteCount(char[] chars, int index, int count) {
            int byteCount = GetBytes(chars, index, count, null, 0);
            return byteCount; 
        }
 
        public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { 
            OciHandle   ociHandle = Handle;
            int         byteCount = checked((int)ociHandle.GetBytes(chars, charIndex, unchecked((uint)charCount), bytes, byteIndex)); 
            return byteCount;
        }

        public override int GetCharCount(byte[] bytes, int index, int count) { 
            int charCount = GetChars(bytes, index, count, null, 0);
            return charCount; 
        } 

        public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { 
            OciHandle   ociHandle = Handle;
            int         charCount = checked((int)ociHandle.GetChars(bytes, byteIndex, unchecked((uint)byteCount), chars, charIndex));
            return charCount;
        } 

        public override int GetMaxByteCount(int charCount) { 
            return checked (charCount * 4); 
        }
 
        public override int GetMaxCharCount(int byteCount) {
            return byteCount;
        }
    } 
}
 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK