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); } ); }