示例#1
0
        public static void RegisterFunction(string name, int argumentCount, FunctionType functionType, Type instanceType, Delegate callback1, Delegate callback2)
        {
            SQLiteFunctionAttribute sQLiteFunctionAttribute = new SQLiteFunctionAttribute(name, argumentCount, functionType)
            {
                InstanceType = instanceType,
                Callback1    = callback1,
                Callback2    = callback2
            };

            SQLiteFunction.ReplaceFunction(sQLiteFunctionAttribute, null);
        }
示例#2
0
        //[FileIOPermission(SecurityAction.Assert, AllFiles=FileIOPermissionAccess.PathDiscovery)]
        static SQLiteFunction()
        {
            Type[] types;
            SQLiteFunction._registeredFunctions = new Dictionary <SQLiteFunctionAttribute, object>();
            try
            {
                if (UnsafeNativeMethods.GetSettingValue("No_SQLiteFunctions", null) == null)
                {
                    Assembly[]   assemblies = AppDomain.CurrentDomain.GetAssemblies();
                    int          length     = (int)assemblies.Length;
                    AssemblyName name       = Assembly.GetExecutingAssembly().GetName();
                    for (int i = 0; i < length; i++)
                    {
                        bool flag = false;
                        try
                        {
                            AssemblyName[] referencedAssemblies = assemblies[i].GetReferencedAssemblies();
                            int            num  = (int)referencedAssemblies.Length;
                            int            num1 = 0;
                            while (num1 < num)
                            {
                                if (referencedAssemblies[num1].Name != name.Name)
                                {
                                    num1++;
                                }
                                else
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            if (flag)
                            {
                                types = assemblies[i].GetTypes();
                            }
                            else
                            {
                                goto Label0;
                            }
                        }
                        catch (ReflectionTypeLoadException reflectionTypeLoadException)
                        {
                            types = reflectionTypeLoadException.Types;
                        }
                        int length1 = (int)types.Length;
                        for (int j = 0; j < length1; j++)
                        {
                            if (types[j] != null)
                            {
                                object[] customAttributes = types[j].GetCustomAttributes(typeof(SQLiteFunctionAttribute), false);
                                int      length2          = (int)customAttributes.Length;
                                for (int k = 0; k < length2; k++)
                                {
                                    SQLiteFunctionAttribute sQLiteFunctionAttribute = customAttributes[k] as SQLiteFunctionAttribute;
                                    if (sQLiteFunctionAttribute != null)
                                    {
                                        sQLiteFunctionAttribute.InstanceType = types[j];
                                        SQLiteFunction.ReplaceFunction(sQLiteFunctionAttribute, null);
                                    }
                                }
                            }
                        }
Label0:
                        break;
                    }
                }
            }
            catch
            {
            }
        }