OracleLob.cs :  » 2.6.4-mono-.net-core » System.Data » System » Data » OracleClient » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » 2.6.4 mono .net core » System.Data 
System.Data » System » Data » OracleClient » OracleLob.cs

using System;
using System.Data.SqlTypes;
using System.IO;
using System.Text;

namespace System.Data.OracleClient{
  public sealed class OracleLob : Stream, ICloneable, INullable {
    #region Fields

    public static readonly new OracleLob Null = new OracleLob ();

    internal OracleConnection connection;
    bool isBatched = false;
    bool isOpen = true;
    bool notNull = false;
    OracleType type;

    long length = -1;
    long position = 0;

    #endregion // Fields

    #region Constructors

    internal OracleLob () {
    }


    #endregion // Constructors

    #region Properties

    public override bool CanRead {
      get { return (IsNull || isOpen); }
    }

    public override bool CanSeek {
      get { return (IsNull || isOpen); }
    }

    public override bool CanWrite {
      get { return isOpen; }
    }

    public int ChunkSize {
      [MonoTODO]
      get { 
        AssertConnectionIsOpen ();
        AssertObjectNotDisposed ();
        throw new NotImplementedException ();
      }
    }

    public OracleConnection Connection {
      get { return connection; }
    }

    public bool IsBatched {
      get { return isBatched; }
    }

    public bool IsNull {
      get { return !notNull; }
    }

    public bool IsTemporary {
      get { 
        AssertConnectionIsOpen ();
        AssertObjectNotDisposed ();
        throw new NotImplementedException ();
      }
    }

    public override long Length {
      get { 
        AssertConnectionIsOpen ();
        AssertObjectNotDisposed ();
        throw new NotImplementedException ();
      }
    }

    public OracleType LobType {
      get { return type; }
    }

    public override long Position {
      get { 
        AssertConnectionIsOpen ();
        AssertObjectNotDisposed ();
        return position;
      }
      set {
        AssertConnectionIsOpen ();
        AssertObjectNotDisposed ();
        position = value;
      }
    }

    public object Value {
      get { 
        AssertObjectNotDisposed ();
        if (IsNull)
          return DBNull.Value;
        
        byte[] buffer = null;

        int len = (int) Length;
        if (len == 0) {
          // LOB is not Null, but it is Empty
          if (LobType == OracleType.Clob)
            return "";
          else // OracleType.Blob
            return new byte[0];
        }

        if (LobType == OracleType.Clob) {
          buffer = new byte [len];
          Read (buffer, 0, len);
          UnicodeEncoding encoding = new UnicodeEncoding ();
          return encoding.GetString (buffer);
        }
        else {
          // OracleType.Blob
          buffer = new byte [len];
          Read (buffer, 0, len);
          return buffer;
        }
      }
    }

    #endregion // Properties

    #region Methods

    [MonoTODO]
    public void Append (OracleLob source) {
      if (source.IsNull)
        throw new ArgumentNullException ();
      if (Connection.State == ConnectionState.Closed)
        throw new InvalidOperationException ();
      throw new NotImplementedException ();
    }

    void AssertAmountIsEven (long amount, string argName) {
      if (amount % 2 == 1)
        throw new ArgumentOutOfRangeException ("CLOB and NCLOB parameters require even number of bytes for this argument.");
    }

    void AssertAmountIsValid (long amount, string argName) {
      if (amount > UInt32.MaxValue)
        throw new ArgumentOutOfRangeException ("Argument too big.");
      if (LobType == OracleType.Clob || LobType == OracleType.NClob)
        AssertAmountIsEven (amount, argName);
    }

    void AssertConnectionIsOpen () {
      if (connection.State == ConnectionState.Closed)
        throw new InvalidOperationException ("Invalid operation. The connection is closed.");
    }

    void AssertObjectNotDisposed () {
      if (!isOpen)
        throw new ObjectDisposedException ("OracleLob");
    }

    void AssertTransactionExists () {
//      if (connection.Transaction == null)
//        throw new InvalidOperationException ("Modifying a LOB requires that the connection be transacted.");
      throw new NotImplementedException ();
    }

    public void BeginBatch () {
      BeginBatch (OracleLobOpenMode.ReadOnly);
    }

    public void BeginBatch (OracleLobOpenMode mode) {
      AssertConnectionIsOpen ();
      AssertObjectNotDisposed ();

      isBatched = true;
    }

    [MonoTODO]
    public object Clone () {
      throw new NotImplementedException ();
    }

    [MonoTODO]
    public override void Close () {
      isOpen = false;
    }

    public long CopyTo (OracleLob destination) {
      return CopyTo (0, destination, 0, Length);
    }

    public long CopyTo (OracleLob destination, long destinationOffset) {
      return CopyTo (0, destination, destinationOffset, Length);
    }

    public long CopyTo (long sourceOffset, OracleLob destination, long destinationOffset, long amount) {
      if (destination.IsNull)
        throw new ArgumentNullException ();

      AssertAmountIsValid (sourceOffset, "sourceOffset");
      AssertAmountIsValid (destinationOffset, "destinationOffset");
      AssertAmountIsValid (amount, "amount");
      AssertTransactionExists ();
      AssertConnectionIsOpen ();

      throw new NotImplementedException ();
    }

    [MonoTODO]
    public void Dispose () {
      throw new NotImplementedException ();
    }

    public void EndBatch () {
      AssertConnectionIsOpen ();
      AssertObjectNotDisposed ();

      isBatched = false;
    }

    public long Erase () {
      return Erase (0, Length);
    }

    public long Erase (long offset, long amount) {
      if (offset < 0 || amount < 0)
        throw new ArgumentOutOfRangeException ("Must be a positive value.");
      if (offset + amount > Length)
        throw new ArgumentOutOfRangeException ();

      AssertAmountIsValid (offset, "offset");
      AssertAmountIsValid (amount, "amount");

      throw new NotImplementedException ();
    }

    public override void Flush () {
      // No-op
    }

    public override int Read (byte[] buffer, int offset, int count) {
      if (buffer == null)
        throw new ArgumentNullException ();

      AssertAmountIsValid (offset, "offset");
      AssertAmountIsValid (count, "count");
      AssertConnectionIsOpen ();
      AssertObjectNotDisposed ();

      throw new NotImplementedException ();

      int bytesRead;
      byte[] output = new byte[count];

      output.CopyTo (buffer, offset);
      position += bytesRead;
      return bytesRead;
    }

    [MonoTODO]
    public override long Seek (long offset, SeekOrigin origin) {
      long newPosition = position;

      switch (origin) {
        case SeekOrigin.Begin:
          newPosition = offset;
          break;
        case SeekOrigin.Current:
          newPosition += offset;
          break;
        case SeekOrigin.End:
          newPosition = Length + offset;
          break;
      }

      if (newPosition > Length)
        throw new ArgumentOutOfRangeException ();

      position = newPosition;
      return position;
    }

    [MonoTODO]
    public override void SetLength (long value) {
      AssertAmountIsValid (value, "value");
      AssertTransactionExists ();
      AssertConnectionIsOpen ();
      AssertObjectNotDisposed ();

      throw new NotImplementedException ();

      length = value;
    }

    public override void Write (byte[] buffer, int offset, int count) {
      if (buffer == null)
        throw new ArgumentNullException ("Buffer is null.");
      if (offset < 0 || count < 0)
        throw new ArgumentOutOfRangeException ("Must be a positive value.");
      if (offset + count > buffer.Length)
        throw new ArgumentOutOfRangeException ("The offset and count values specified exceed the buffer provided.");
      AssertAmountIsValid (offset, "offset");
      AssertAmountIsValid (count, "count");
      AssertTransactionExists ();
      AssertConnectionIsOpen ();
      AssertObjectNotDisposed ();

      byte[] value = null;
      if (offset + count == buffer.Length && offset == 0)
        value = buffer;
      else {
        value = new byte[count];
        Array.Copy (buffer, offset, value, 0, count);
      }

      throw new NotImplementedException ();

//      position += locator.Write (value, (uint) Position, (uint) value.Length, LobType);
    }

    #endregion // Methods
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.