Exemple #1
0
        internal static bool UnbindFunction(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 funcType = functionAttribute.FuncType;
            string       name     = functionAttribute.Name;

            if (funcType == FunctionType.Collation)
            {
                return(sqliteBase.CreateCollation(name, null, null, false) == SQLiteErrorCode.Ok);
            }
            bool flag = function is SQLiteFunctionEx;

            return(sqliteBase.CreateFunction(name, functionAttribute.Arguments, flag, null, null, null, false) == SQLiteErrorCode.Ok);
        }
Exemple #2
0
        internal static void BindFunction(SQLiteBase sqliteBase, SQLiteFunctionAttribute functionAttribute, SQLiteFunction function, SQLiteConnectionFlags flags)
        {
            SQLiteCallback      sQLiteCallback;
            SQLiteCallback      sQLiteCallback1;
            SQLiteFinalCallback sQLiteFinalCallback;
            SQLiteCollation     sQLiteCollation;
            SQLiteCollation     sQLiteCollation1;

            if (sqliteBase == null)
            {
                throw new ArgumentNullException("sqliteBase");
            }
            if (functionAttribute == null)
            {
                throw new ArgumentNullException("functionAttribute");
            }
            if (function == null)
            {
                throw new ArgumentNullException("function");
            }
            FunctionType funcType = functionAttribute.FuncType;

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

            if (funcType == FunctionType.Scalar)
            {
                sQLiteCallback = new SQLiteCallback(function.ScalarCallback);
            }
            else
            {
                sQLiteCallback = null;
            }
            sQLiteFunction._InvokeFunc = sQLiteCallback;
            SQLiteFunction sQLiteFunction1 = function;

            if (funcType == FunctionType.Aggregate)
            {
                sQLiteCallback1 = new SQLiteCallback(function.StepCallback);
            }
            else
            {
                sQLiteCallback1 = null;
            }
            sQLiteFunction1._StepFunc = sQLiteCallback1;
            SQLiteFunction sQLiteFunction2 = function;

            if (funcType == FunctionType.Aggregate)
            {
                sQLiteFinalCallback = new SQLiteFinalCallback(function.FinalCallback);
            }
            else
            {
                sQLiteFinalCallback = null;
            }
            sQLiteFunction2._FinalFunc = sQLiteFinalCallback;
            SQLiteFunction sQLiteFunction3 = function;

            if (funcType == FunctionType.Collation)
            {
                sQLiteCollation = new SQLiteCollation(function.CompareCallback);
            }
            else
            {
                sQLiteCollation = null;
            }
            sQLiteFunction3._CompareFunc = sQLiteCollation;
            SQLiteFunction sQLiteFunction4 = function;

            if (funcType == FunctionType.Collation)
            {
                sQLiteCollation1 = new SQLiteCollation(function.CompareCallback16);
            }
            else
            {
                sQLiteCollation1 = null;
            }
            sQLiteFunction4._CompareFunc16 = sQLiteCollation1;
            string name = functionAttribute.Name;

            if (funcType == FunctionType.Collation)
            {
                sqliteBase.CreateCollation(name, function._CompareFunc, function._CompareFunc16, true);
                return;
            }
            bool flag = function is SQLiteFunctionEx;

            sqliteBase.CreateFunction(name, functionAttribute.Arguments, flag, function._InvokeFunc, function._StepFunc, function._FinalFunc, true);
        }