public override SQLiteErrorCode Column(SQLiteVirtualTableCursor cursor, SQLiteContext context, int index) { this.CheckDisposed(); SQLiteVirtualTableCursorEnumerator <T> sQLiteVirtualTableCursorEnumerator = cursor as SQLiteVirtualTableCursorEnumerator <T>; if (sQLiteVirtualTableCursorEnumerator == null) { return(this.CursorTypeMismatchError(cursor, typeof(SQLiteVirtualTableCursorEnumerator))); } if (sQLiteVirtualTableCursorEnumerator.EndOfEnumerator) { return(this.CursorEndOfEnumeratorError(cursor)); } T current = ((IEnumerator <T>)sQLiteVirtualTableCursorEnumerator).Current; if (current == null) { context.SetNull(); } else { context.SetString(this.GetStringFromObject(cursor, current)); } return(SQLiteErrorCode.Ok); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the table error message to one that indicates the virtual /// table cursor is of the wrong type. /// </summary> /// <param name="cursor"> /// The <see cref="SQLiteVirtualTableCursor" /> object instance. /// </param> /// <returns> /// The value of <see cref="SQLiteErrorCode.Error" />. /// </returns> protected virtual SQLiteErrorCode CursorTypeMismatchError( SQLiteVirtualTableCursor cursor ) { SetCursorError(cursor, "not an \"enumerator\" cursor"); return(SQLiteErrorCode.Error); }
/////////////////////////////////////////////////////////////////////// #region Protected Methods /// <summary> /// Sets the table error message to one that indicates the virtual /// table cursor has no current row. /// </summary> /// <param name="cursor"> /// The <see cref="SQLiteVirtualTableCursor" /> object instance. /// </param> /// <returns> /// The value of <see cref="SQLiteErrorCode.Error" />. /// </returns> protected virtual SQLiteErrorCode CursorEndOfEnumeratorError( SQLiteVirtualTableCursor cursor ) { SetCursorError(cursor, "already hit end of enumerator"); return(SQLiteErrorCode.Error); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.Column" /> method. /// </summary> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.Column" /> method. /// </param> /// <param name="context"> /// See the <see cref="ISQLiteManagedModule.Column" /> method. /// </param> /// <param name="index"> /// See the <see cref="ISQLiteManagedModule.Column" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.Column" /> method. /// </returns> public override SQLiteErrorCode Column( SQLiteVirtualTableCursor cursor, SQLiteContext context, int index ) { CheckDisposed(); SQLiteVirtualTableCursorEnumerator enumeratorCursor = cursor as SQLiteVirtualTableCursorEnumerator; if (enumeratorCursor == null) { return(CursorTypeMismatchError(cursor, typeof(SQLiteVirtualTableCursorEnumerator))); } if (enumeratorCursor.EndOfEnumerator) { return(CursorEndOfEnumeratorError(cursor)); } object current = enumeratorCursor.Current; if (current != null) { context.SetString(GetStringFromObject(cursor, current)); } else { context.SetNull(); } return(SQLiteErrorCode.Ok); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.RowId" /> method. /// </summary> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.RowId" /> method. /// </param> /// <param name="rowId"> /// See the <see cref="ISQLiteManagedModule.RowId" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.RowId" /> method. /// </returns> public override SQLiteErrorCode RowId( SQLiteVirtualTableCursor cursor, ref long rowId ) { CheckDisposed(); SQLiteVirtualTableCursorEnumerator enumeratorCursor = cursor as SQLiteVirtualTableCursorEnumerator; if (enumeratorCursor == null) { return(CursorTypeMismatchError(cursor, typeof(SQLiteVirtualTableCursorEnumerator))); } if (enumeratorCursor.EndOfEnumerator) { return(CursorEndOfEnumeratorError(cursor)); } object current = enumeratorCursor.Current; rowId = GetRowIdFromObject(cursor, current); return(SQLiteErrorCode.Ok); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.Eof" /> method. /// </summary> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.Eof" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.Eof" /> method. /// </returns> public override bool Eof( SQLiteVirtualTableCursor cursor ) { CheckDisposed(); return(ResultCodeToEofResult(GetMethodResultCode("Eof"))); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.Next" /> method. /// </summary> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.Next" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.Next" /> method. /// </returns> public override SQLiteErrorCode Next( SQLiteVirtualTableCursor cursor ) { CheckDisposed(); return(GetMethodResultCode("Next")); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.RowId" /> method. /// </summary> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.RowId" /> method. /// </param> /// <param name="rowId"> /// See the <see cref="ISQLiteManagedModule.RowId" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.RowId" /> method. /// </returns> public override SQLiteErrorCode RowId( SQLiteVirtualTableCursor cursor, ref long rowId ) { CheckDisposed(); return(GetMethodResultCode("RowId")); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.Open" /> method. /// </summary> /// <param name="table"> /// See the <see cref="ISQLiteManagedModule.Open" /> method. /// </param> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.Open" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.Open" /> method. /// </returns> public override SQLiteErrorCode Open( SQLiteVirtualTable table, ref SQLiteVirtualTableCursor cursor ) { CheckDisposed(); return(GetMethodResultCode("Open")); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.Column" /> method. /// </summary> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.Column" /> method. /// </param> /// <param name="context"> /// See the <see cref="ISQLiteManagedModule.Column" /> method. /// </param> /// <param name="index"> /// See the <see cref="ISQLiteManagedModule.Column" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.Column" /> method. /// </returns> public override SQLiteErrorCode Column( SQLiteVirtualTableCursor cursor, SQLiteContext context, int index ) { CheckDisposed(); return(GetMethodResultCode("Column")); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// Determines the unique row identifier for the current row. /// </summary> /// <param name="cursor"> /// The <see cref="SQLiteVirtualTableCursor" /> object instance /// associated with the previously opened virtual table cursor to be /// used. /// </param> /// <param name="value"> /// The object instance to return a unique row identifier for. /// </param> /// <returns> /// The unique row identifier or zero upon failure. /// </returns> protected virtual long GetRowIdFromObject( SQLiteVirtualTableCursor cursor, object value ) { int rowIndex = (cursor != null) ? cursor.GetRowIndex() : 0; int hashCode = SQLiteMarshal.GetHashCode(value, objectIdentity); return(MakeRowId(rowIndex, hashCode)); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </summary> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </param> /// <param name="indexNumber"> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </param> /// <param name="indexString"> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </param> /// <param name="values"> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </returns> public override SQLiteErrorCode Filter( SQLiteVirtualTableCursor cursor, int indexNumber, string indexString, SQLiteValue[] values ) { CheckDisposed(); return(GetMethodResultCode("Filter")); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.Open" /> method. /// </summary> /// <param name="table"> /// See the <see cref="ISQLiteManagedModule.Open" /> method. /// </param> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.Open" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.Open" /> method. /// </returns> public override SQLiteErrorCode Open( SQLiteVirtualTable table, ref SQLiteVirtualTableCursor cursor ) { CheckDisposed(); cursor = new SQLiteVirtualTableCursorEnumerator( table, enumerable.GetEnumerator()); return(SQLiteErrorCode.Ok); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.Eof" /> method. /// </summary> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.Eof" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.Eof" /> method. /// </returns> public override bool Eof( SQLiteVirtualTableCursor cursor ) { CheckDisposed(); SQLiteVirtualTableCursorEnumerator enumeratorCursor = cursor as SQLiteVirtualTableCursorEnumerator; if (enumeratorCursor == null) { return(ResultCodeToEofResult(CursorTypeMismatchError(cursor))); } return(enumeratorCursor.EndOfEnumerator); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// Determines the string to return as the column value for the object /// instance value. /// </summary> /// <param name="cursor"> /// The <see cref="SQLiteVirtualTableCursor" /> object instance /// associated with the previously opened virtual table cursor to be /// used. /// </param> /// <param name="value"> /// The object instance to return a string representation for. /// </param> /// <returns> /// The string representation of the specified object instance or null /// upon failure. /// </returns> protected virtual string GetStringFromObject( SQLiteVirtualTableCursor cursor, object value ) { if (value == null) { return(null); } if (value is string) { return((string)value); } return(value.ToString()); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.Close" /> method. /// </summary> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.Close" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.Close" /> method. /// </returns> public override SQLiteErrorCode Close( SQLiteVirtualTableCursor cursor ) { CheckDisposed(); SQLiteVirtualTableCursorEnumerator enumeratorCursor = cursor as SQLiteVirtualTableCursorEnumerator; if (enumeratorCursor == null) { return(CursorTypeMismatchError(cursor)); } enumeratorCursor.Close(); return(SQLiteErrorCode.Ok); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the table error message to one that indicates the virtual /// table cursor is of the wrong type. /// </summary> /// <param name="cursor"> /// The <see cref="SQLiteVirtualTableCursor" /> object instance. /// </param> /// <param name="type"> /// The <see cref="Type" /> that the virtual table cursor should be. /// </param> /// <returns> /// The value of <see cref="SQLiteErrorCode.Error" />. /// </returns> protected virtual SQLiteErrorCode CursorTypeMismatchError( SQLiteVirtualTableCursor cursor, Type type ) { if (type != null) { SetCursorError(cursor, String.Format("not a \"{0}\" cursor", type)); } else { SetCursorError(cursor, "cursor type mismatch"); } return(SQLiteErrorCode.Error); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the table error message to one that indicates the virtual /// table cursor is of the wrong type. /// </summary> /// <param name="cursor"> /// The <see cref="SQLiteVirtualTableCursor" /> object instance. /// </param> /// <param name="type"> /// The <see cref="Type" /> that the virtual table cursor should be. /// </param> /// <returns> /// The value of <see cref="SQLiteErrorCode.Error" />. /// </returns> protected virtual SQLiteErrorCode CursorTypeMismatchError( SQLiteVirtualTableCursor cursor, Type type ) { if (type != null) { SetCursorError(cursor, HelperMethods.StringFormat( CultureInfo.CurrentCulture, "not a \"{0}\" cursor", type)); } else { SetCursorError(cursor, "cursor type mismatch"); } return(SQLiteErrorCode.Error); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.Next" /> method. /// </summary> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.Next" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.Next" /> method. /// </returns> public override SQLiteErrorCode Next( SQLiteVirtualTableCursor cursor ) { CheckDisposed(); SQLiteVirtualTableCursorEnumerator enumeratorCursor = cursor as SQLiteVirtualTableCursorEnumerator; if (enumeratorCursor == null) { return(CursorTypeMismatchError(cursor)); } if (enumeratorCursor.EndOfEnumerator) { return(CursorEndOfEnumeratorError(cursor)); } enumeratorCursor.MoveNext(); /* IGNORED */ return(SQLiteErrorCode.Ok); }
/////////////////////////////////////////////////////////////////////// /// <summary> /// Determines the unique row identifier for the current row. /// </summary> /// <param name="cursor"> /// The <see cref="SQLiteVirtualTableCursor" /> object instance /// associated with the previously opened virtual table cursor to be /// used. /// </param> /// <param name="value"> /// The object instance to return a unique row identifier for. /// </param> /// <returns> /// The unique row identifier or zero upon failure. /// </returns> protected virtual long GetRowIdFromObject( SQLiteVirtualTableCursor cursor, object value ) { if ((cursor != null) && (value != null)) { return(MakeRowId(cursor.GetRowIndex(), value.GetHashCode())); } else if (cursor != null) { return(cursor.GetRowIndex()); } else if (value != null) { return(value.GetHashCode()); } else { return(0); } }
/////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </summary> /// <param name="cursor"> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </param> /// <param name="indexNumber"> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </param> /// <param name="indexString"> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </param> /// <param name="values"> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteManagedModule.Filter" /> method. /// </returns> public override SQLiteErrorCode Filter( SQLiteVirtualTableCursor cursor, int indexNumber, string indexString, SQLiteValue[] values ) { CheckDisposed(); SQLiteVirtualTableCursorEnumerator enumeratorCursor = cursor as SQLiteVirtualTableCursorEnumerator; if (enumeratorCursor == null) { return(CursorTypeMismatchError(cursor)); } enumeratorCursor.Filter(indexNumber, indexString, values); enumeratorCursor.Reset(); /* NO RESULT */ enumeratorCursor.MoveNext(); /* IGNORED */ return(SQLiteErrorCode.Ok); }