コード例 #1
0
        public static void Factory(ExternalContext Context, Action <GearsFactory> Handler)
        {
            var f = new GearsFactory
            {
                Context = new GearsContext(Context)
            };

            Context.ToPlugin("GearsFactory", "Gears.Factory", "application/x-googlegears",
                             GoogleGears_Factory =>
            {
                if (GoogleGears_Factory == null)
                {
                    Handler(null);
                    return;
                }

                f.GetBuildInfo =
                    () => f.Context.GoogleGears_Factory_getBuildInfo(GoogleGears_Factory);

                f.GetPermission =
                    (siteName, imageUrl, extraMessage) =>
                    f.Context.GoogleGears_Factory_getPermission(siteName, imageUrl, extraMessage, GoogleGears_Factory);

                f.Create =
                    (id, version) =>
                {
                    // database will be saved here
                    var GoogleGears_Database = Context.CreateToken();

                    f.Context.GoogleGears_Factory_create(id, version, GoogleGears_Factory, GoogleGears_Database);

                    return(GoogleGears_Database);
                };

                Handler(f);
            }
                             );
        }
コード例 #2
0
            public Database(GearsFactory GearsFactory)
            {
                this.GearsFactory = GearsFactory;

                var DatabaseToken = GearsFactory.Create("beta.database", "1.0");

                this.Open = n => GearsFactory.Context.Context.ExternalContext_token_call_string(DatabaseToken, "open", n);

                this.Execute =
                    (sqlStatement, argArray) =>
                {
                    var ResultSetToken = GearsFactory.Context.Context.CreateToken();

                    if (BeforeExecute != null)
                    {
                        BeforeExecute(sqlStatement);
                    }

                    GearsFactory.Context.GoogleGears_Database_execute(sqlStatement, argArray, DatabaseToken, ResultSetToken);

                    return(new ResultSet(GearsFactory.Context, ResultSetToken));
                };
            }