Beispiel #1
0
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (!this.disposed && disposing)
         {
             if (this.outputStreamAdapter != null)
             {
                 this.outputStreamAdapter.Dispose();
                 this.outputStreamAdapter = null;
             }
             if (this.inputStreamAdapter != null)
             {
                 this.inputStreamAdapter.Dispose();
                 this.inputStreamAdapter = null;
             }
             if (this.outputStream != null)
             {
                 this.outputStream = null;
             }
             if (this.inputStream != null)
             {
                 this.inputStream = null;
             }
         }
     }
     finally
     {
         base.Dispose(disposing);
         this.disposed = true;
     }
 }
Beispiel #2
0
 private void CheckOutputStream()
 {
     if (this.outputStream == null)
     {
         throw new InvalidOperationException("output stream unavailable");
     }
     if (this.outputStreamAdapter == null)
     {
         this.outputStreamAdapter = new SQLiteStreamAdapter(this.outputStream, base.GetFlags());
     }
 }
Beispiel #3
0
        public SQLiteStreamAdapter GetAdapter(Stream stream)
        {
            SQLiteStreamAdapter sQLiteStreamAdapter;

            this.CheckDisposed();
            if (stream == null)
            {
                return(null);
            }
            if (this.streamAdapters.TryGetValue(stream, out sQLiteStreamAdapter))
            {
                return(sQLiteStreamAdapter);
            }
            sQLiteStreamAdapter = new SQLiteStreamAdapter(stream, this.flags);
            this.streamAdapters.Add(stream, sQLiteStreamAdapter);
            return(sQLiteStreamAdapter);
        }
Beispiel #4
0
 private void DisposeStreamAdapters()
 {
     if (this.streamAdapters == null)
     {
         return;
     }
     foreach (KeyValuePair <Stream, SQLiteStreamAdapter> streamAdapter in this.streamAdapters)
     {
         SQLiteStreamAdapter value = streamAdapter.Value;
         if (value == null)
         {
             continue;
         }
         value.Dispose();
     }
     this.streamAdapters.Clear();
     this.streamAdapters = null;
 }
Beispiel #5
0
        public void CreatePatchSet(Stream stream)
        {
            this.CheckDisposed();
            this.CheckHandle();
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            SQLiteStreamAdapter streamAdapter = this.GetStreamAdapter(stream);

            if (streamAdapter == null)
            {
                throw new SQLiteException("could not get or create adapter for output stream");
            }
            SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3session_patchset_strm(this.session, streamAdapter.GetOutputDelegate(), IntPtr.Zero);

            if (sQLiteErrorCode != SQLiteErrorCode.Ok)
            {
                throw new SQLiteException(sQLiteErrorCode, "sqlite3session_patchset_strm");
            }
        }
        public void AddChangeSet(Stream stream)
        {
            this.CheckDisposed();
            this.CheckHandle();
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            SQLiteStreamAdapter streamAdapter = this.GetStreamAdapter(stream);

            if (streamAdapter == null)
            {
                throw new SQLiteException("could not get or create adapter for input stream");
            }
            SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3changegroup_add_strm(this.changeGroup, streamAdapter.GetInputDelegate(), IntPtr.Zero);

            if (sQLiteErrorCode != SQLiteErrorCode.Ok)
            {
                throw new SQLiteException(sQLiteErrorCode, "sqlite3changegroup_add_strm");
            }
        }
Beispiel #7
0
        public static SQLiteStreamChangeSetIterator Create(Stream stream, SQLiteConnectionFlags flags)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            SQLiteStreamAdapter           sQLiteStreamAdapter           = null;
            SQLiteStreamChangeSetIterator sQLiteStreamChangeSetIterator = null;
            IntPtr zero = IntPtr.Zero;

            try
            {
                sQLiteStreamAdapter = new SQLiteStreamAdapter(stream, flags);
                SQLiteErrorCode sQLiteErrorCode = UnsafeNativeMethods.sqlite3changeset_start_strm(ref zero, sQLiteStreamAdapter.GetInputDelegate(), IntPtr.Zero);
                if (sQLiteErrorCode != SQLiteErrorCode.Ok)
                {
                    throw new SQLiteException(sQLiteErrorCode, "sqlite3changeset_start_strm");
                }
                sQLiteStreamChangeSetIterator = new SQLiteStreamChangeSetIterator(sQLiteStreamAdapter, zero, true);
            }
            finally
            {
                if (sQLiteStreamChangeSetIterator == null)
                {
                    if (zero != IntPtr.Zero)
                    {
                        UnsafeNativeMethods.sqlite3changeset_finalize(zero);
                        zero = IntPtr.Zero;
                    }
                    if (sQLiteStreamAdapter != null)
                    {
                        sQLiteStreamAdapter.Dispose();
                        sQLiteStreamAdapter = null;
                    }
                }
            }
            return(sQLiteStreamChangeSetIterator);
        }
Beispiel #8
0
 private SQLiteStreamChangeSetIterator(SQLiteStreamAdapter streamAdapter, IntPtr iterator, bool ownHandle) : base(iterator, ownHandle)
 {
     this.streamAdapter = streamAdapter;
 }