Example #1
0
        /// <summary>
        /// This function binds a user-defined functions to a connection.
        /// </summary>
        /// <param name="sqliteBase">
        /// The <see cref="SQLiteBase" /> object instance associated with the
        /// <see cref="SQLiteConnection" /> that the function should be bound to.
        /// </param>
        /// <param name="functionAttribute">
        /// The <see cref="SQLiteFunctionAttribute"/> object instance containing
        /// the metadata for the function to be bound.
        /// </param>
        /// <param name="function">
        /// The <see cref="SQLiteFunction"/> object instance that implements the
        /// function to be bound.
        /// </param>
        /// <param name="flags">
        /// The flags associated with the parent connection object.
        /// </param>
        internal static void BindFunction(
            SQLiteBase sqliteBase,
            SQLiteFunctionAttribute functionAttribute,
            SQLiteFunction function,
            SQLiteConnectionFlags flags
            )
        {
            if (sqliteBase == null)
            {
                throw new ArgumentNullException("sqliteBase");
            }

            if (functionAttribute == null)
            {
                throw new ArgumentNullException("functionAttribute");
            }

            if (function == null)
            {
                throw new ArgumentNullException("function");
            }

            FunctionType functionType = functionAttribute.FuncType;

            function._base  = sqliteBase;
            function._flags = flags;

            function._InvokeFunc = (functionType == FunctionType.Scalar) ?
                                   new SQLiteCallback(function.ScalarCallback) : null;

            function._StepFunc = (functionType == FunctionType.Aggregate) ?
                                 new SQLiteCallback(function.StepCallback) : null;

            function._FinalFunc = (functionType == FunctionType.Aggregate) ?
                                  new SQLiteFinalCallback(function.FinalCallback) : null;

            function._CompareFunc = (functionType == FunctionType.Collation) ?
                                    new SQLiteCollation(function.CompareCallback) : null;

            function._CompareFunc16 = (functionType == FunctionType.Collation) ?
                                      new SQLiteCollation(function.CompareCallback16) : null;

            string name = functionAttribute.Name;

            if (functionType != FunctionType.Collation)
            {
                bool needCollSeq = (function is SQLiteFunctionEx);

                sqliteBase.CreateFunction(
                    name, functionAttribute.Arguments, needCollSeq,
                    function._InvokeFunc, function._StepFunc,
                    function._FinalFunc);
            }
            else
            {
                sqliteBase.CreateCollation(
                    name, function._CompareFunc, function._CompareFunc16);
            }
        }
Example #2
0
    /// <summary>
    /// This function binds a user-defined functions to a connection.
    /// </summary>
    /// <param name="sqliteBase">
    /// The <see cref="SQLiteBase" /> object instance associated with the
    /// <see cref="SQLiteConnection" /> that the function should be bound to.
    /// </param>
    /// <param name="functionAttribute">
    /// The <see cref="SQLiteFunctionAttribute"/> object instance containing
    /// the metadata for the function to be bound.
    /// </param>
    /// <param name="function">
    /// The <see cref="SQLiteFunction"/> object instance that implements the
    /// function to be bound.
    /// </param>
    /// <param name="flags">
    /// The flags associated with the parent connection object.
    /// </param>
    internal static void BindFunction(
        SQLiteBase sqliteBase,
        SQLiteFunctionAttribute functionAttribute,
        SQLiteFunction function,
        SQLiteConnectionFlags flags
        )
    {
        if (sqliteBase == null)
            throw new ArgumentNullException("sqliteBase");

        if (functionAttribute == null)
            throw new ArgumentNullException("functionAttribute");

        if (function == null)
            throw new ArgumentNullException("function");

        FunctionType functionType = functionAttribute.FuncType;

        function._base = sqliteBase;
        function._flags = flags;

        function._InvokeFunc = (functionType == FunctionType.Scalar) ?
            new SQLiteCallback(function.ScalarCallback) : null;

        function._StepFunc = (functionType == FunctionType.Aggregate) ?
            new SQLiteCallback(function.StepCallback) : null;

        function._FinalFunc = (functionType == FunctionType.Aggregate) ?
            new SQLiteFinalCallback(function.FinalCallback) : null;

        function._CompareFunc = (functionType == FunctionType.Collation) ?
            new SQLiteCollation(function.CompareCallback) : null;

        function._CompareFunc16 = (functionType == FunctionType.Collation) ?
            new SQLiteCollation(function.CompareCallback16) : null;

        string name = functionAttribute.Name;

        if (functionType != FunctionType.Collation)
        {
            bool needCollSeq = (function is SQLiteFunctionEx);

            sqliteBase.CreateFunction(
                name, functionAttribute.Arguments, needCollSeq,
                function._InvokeFunc, function._StepFunc,
                function._FinalFunc);
        }
        else
        {
            sqliteBase.CreateCollation(
                name, function._CompareFunc, function._CompareFunc16);
        }
    }
Example #3
0
    /// <summary>
    /// This function binds a user-defined function to the connection.
    /// </summary>
    /// <param name="functionAttribute">
    /// The <see cref="SQLiteFunctionAttribute"/> object instance containing
    /// the metadata for the function to be bound.
    /// </param>
    /// <param name="function">
    /// The <see cref="SQLiteFunction"/> object instance that implements the
    /// function to be bound.
    /// </param>
    /// <param name="flags">
    /// The flags associated with the parent connection object.
    /// </param>
    internal override void BindFunction(
        SQLiteFunctionAttribute functionAttribute,
        SQLiteFunction function,
        SQLiteConnectionFlags flags
        )
    {
        SQLiteFunction.BindFunction(this, functionAttribute, function, flags);

        if (_functions == null)
            _functions = new List<SQLiteFunction>();

        _functions.Add(function);
    }
Example #4
0
 /// <summary>
 /// This function binds a user-defined functions to the connection.
 /// </summary>
 /// <param name="functionAttribute">
 /// The <see cref="SQLiteFunctionAttribute"/> object instance containing
 /// the metadata for the function to be bound.
 /// </param>
 /// <param name="function">
 /// The <see cref="SQLiteFunction"/> object instance that implements the
 /// function to be bound.
 /// </param>
 /// <param name="flags">
 /// The flags associated with the parent connection object.
 /// </param>
 internal abstract void BindFunction(SQLiteFunctionAttribute functionAttribute, SQLiteFunction function, SQLiteConnectionFlags flags);