Beispiel #1
0
        /// <summary>
        /// Disposes of any active contextData variables that were not automatically cleaned up.  Sometimes this can happen if
        /// someone closes the connection while a DataReader is open.
        /// </summary>
        public void Dispose()
        {
            Dispose(true);

            IDisposable disp;

            foreach (KeyValuePair <long, object> kv in _contextDataList)
            {
                disp = kv.Value as IDisposable;
                if (disp != null)
                {
                    disp.Dispose();
                }
            }
            _contextDataList.Clear();

            _InvokeFunc      = null;
            _StepFunc        = null;
            _FinalFunc       = null;
            _CompareFunc     = null;
            _base            = null;
            _contextDataList = null;

            GC.SuppressFinalize(this);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Column"/> class.
        /// </summary>
        /// <param name="columnName">The column name.</param>
        /// <param name="typeDefinition">The type definition.</param>
        /// <param name="nullable">If set to <c>true</c> indicates the column is nullable.</param>
        /// <param name="autoIncrement">If set to <c>true</c> the column automatically increments.</param>
        /// <param name="collation">The column collation.</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="computedDefinition">The computed definition.</param>
        /// <param name="computedColumnType">The computed column type.</param>
        /// <exception cref="ArgumentNullException"><paramref name="columnName"/> is <c>null</c>, empty or whitespace.</exception>
        /// <exception cref="ArgumentException"><paramref name="collation"/> or <paramref name="computedColumnType"/> are invalid enum values.</exception>
        public Column(
            string columnName,
            IEnumerable <Token <SqliteToken> > typeDefinition,
            bool nullable,
            bool autoIncrement,
            SqliteCollation collation,
            IEnumerable <Token <SqliteToken> > defaultValue,
            IEnumerable <Token <SqliteToken> > computedDefinition,
            SqliteGeneratedColumnType computedColumnType
            )
        {
            if (columnName.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(columnName));
            }
            if (!collation.IsValid())
            {
                throw new ArgumentException($"The { nameof(SqliteCollation) } provided must be a valid enum.", nameof(collation));
            }
            if (!computedColumnType.IsValid())
            {
                throw new ArgumentException($"The { nameof(SqliteGeneratedColumnType) } provided must be a valid enum.", nameof(computedColumnType));
            }

            Name               = columnName;
            TypeDefinition     = typeDefinition?.ToList() ?? Enumerable.Empty <Token <SqliteToken> >();
            Nullable           = nullable;
            IsAutoIncrement    = autoIncrement;
            Collation          = collation;
            DefaultValue       = defaultValue?.ToList() ?? Enumerable.Empty <Token <SqliteToken> >();
            ComputedDefinition = computedDefinition?.ToList() ?? Enumerable.Empty <Token <SqliteToken> >();
            ComputedColumnType = computedColumnType;
        }
Beispiel #3
0
        internal override void CreateCollation(string strCollation, SqliteCollation func)
        {
            int n = UnsafeNativeMethods.sqlite3_create_collation16(_sql, strCollation, 4, IntPtr.Zero, func);

            if (n > 0)
            {
                throw new SqliteException(n, SqliteLastError());
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SqliteColumnType"/> class.
        /// </summary>
        /// <param name="typeAffinity">The type affinity.</param>
        /// <param name="collation">The collation.</param>
        /// <exception cref="ArgumentException"><paramref name="collation"/> or <paramref name="typeAffinity"/> are invalid enum values. Alternatively if the <paramref name="collation"/> is not <see cref="SqliteTypeAffinity.Text"/>.</exception>
        public SqliteColumnType(SqliteTypeAffinity typeAffinity, SqliteCollation collation)
            : this(typeAffinity)
        {
            if (!typeAffinity.IsValid())
            {
                throw new ArgumentException($"The { nameof(SqliteTypeAffinity) } provided must be a valid enum.", nameof(typeAffinity));
            }
            if (!collation.IsValid())
            {
                throw new ArgumentException($"The { nameof(SqliteCollation) } provided must be a valid enum.", nameof(collation));
            }
            if (typeAffinity != SqliteTypeAffinity.Text)
            {
                throw new ArgumentException("The type affinity must be a text type when a collation has been provided.", nameof(typeAffinity));
            }

            Collation = collation != SqliteCollation.None
                ? Option <Identifier> .Some(collation.ToString().ToUpperInvariant())
                : Option <Identifier> .None;
        }
Beispiel #5
0
        /// <summary>
        /// Placeholder for a user-defined disposal routine
        /// </summary>
        /// <param name="disposing">True if the object is being disposed explicitly</param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                IDisposable disp;

                foreach (KeyValuePair <SqliteValueHandle, AggregateData> kv in _contextDataList)
                {
                    disp = kv.Value._data as IDisposable;
                    if (disp != null)
                    {
                        disp.Dispose();
                    }
                }
                _contextDataList.Clear();

                _InvokeFunc      = null;
                _StepFunc        = null;
                _FinalFunc       = null;
                _CompareFunc     = null;
                _base            = null;
                _contextDataList = null;
            }
        }
Beispiel #6
0
 internal abstract void  CreateCollation(string strCollation, SqliteCollation func);
 internal abstract void CreateCollation(string strCollation, SqliteCollation func, SqliteCollation func16);
Beispiel #8
0
 internal override void CreateCollation(string strCollation, SqliteCollation func)
 {
   int n = UnsafeNativeMethods.sqlite3_create_collation16(_sql, strCollation, 4, IntPtr.Zero, func);
   if (n > 0) throw new SqliteException(n, SqliteLastError());
 }
        /// <summary>
        /// Placeholder for a user-defined disposal routine
        /// </summary>
        /// <param name="disposing">True if the object is being disposed explicitly</param>
        protected virtual void Dispose(bool disposing) {
            if (disposing) {
                IDisposable disp;

                foreach (KeyValuePair<SqliteValueHandle, AggregateData> kv in _contextDataList) {
                    disp = kv.Value._data as IDisposable;
                    if (disp != null)
                        disp.Dispose();
                }
                _contextDataList.Clear();

                _InvokeFunc = null;
                _StepFunc = null;
                _FinalFunc = null;
                _CompareFunc = null;
                _base = null;
                _contextDataList = null;
            }
        }
Beispiel #10
0
 internal static extern int sqlite3_create_collation16(IntPtr db, string strName, int eTextRep, IntPtr ctx, SqliteCollation fcompare);
Beispiel #11
0
    /// <summary>
    /// Disposes of any active contextData variables that were not automatically cleaned up.  Sometimes this can happen if
    /// someone closes the connection while a DataReader is open.
    /// </summary>
    public void Dispose()
    {
      Dispose(true);

      IDisposable disp;

      foreach (KeyValuePair<long, object> kv in _contextDataList)
      {
        disp = kv.Value as IDisposable;
        if (disp != null)
          disp.Dispose();
      }
      _contextDataList.Clear();

      _InvokeFunc = null;
      _StepFunc = null;
      _FinalFunc = null;
      _CompareFunc = null;
      _base = null;
      _contextDataList = null;

      GC.SuppressFinalize(this);
    }
Beispiel #12
0
 internal static extern int sqlite3_create_collation16(IntPtr db, string strName, int eTextRep, IntPtr ctx, SqliteCollation fcompare);