Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace AzureTest
- open System
- open System.Runtime
- open System.Drawing
- open MonoTouch.UIKit
- open MonoTouch.Foundation
- open Microsoft.WindowsAzure.MobileServices
- open Microsoft.WindowsAzure.MobileServices.Sync
- open Microsoft.WindowsAzure.MobileServices.SQLiteStore
- [<CLIMutable>]
- type TodoItem = { Id: string; Text: string; Complete: bool }
- [<Register ("AzureTestViewController")>]
- type AzureTestViewController () =
- inherit UIViewController ()
- // Release any cached data, images, etc that aren't in use.
- override this.DidReceiveMemoryWarning () =
- base.DidReceiveMemoryWarning ()
- // Perform any additional setup after loading the view, typically from a nib.
- override this.ViewDidLoad () =
- base.ViewDidLoad ()
- CurrentPlatform.Init ()
- SQLitePCL.CurrentPlatform.Init () // add this line
- // Initialize the Mobile Service client with your URL and key
- let client = new MobileServiceClient ("***", "***")
- // Create an MSTable instance to allow us to work with the TodoItem table
- let item = { Id = null; Text = "Awesome item"; Complete = false }
- //let itemTable = client.GetTable<TodoItem>()
- //let itemTable = client.GetTable<Item> ()
- match client.SyncContext.IsInitialized with
- | false ->
- use store = new MobileServiceSQLiteStore ("baby.db")
- store.DefineTable<TodoItem> ()
- client.SyncContext.InitializeAsync(store, MobileServiceSyncHandler ()).Wait ()
- | _ -> ()
- // protected async override void OnNavigatedTo(NavigationEventArgs e)
- // {
- // if (!App.MobileService.SyncContext.IsInitialized)
- // {
- // var store = new MobileServiceSQLiteStore("localsync12.db");
- // store.DefineTable<TodoItem>();
- // await App.MobileService.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());
- // }
- // RefreshTodoItems();
- // }
- let todoTable = client.GetSyncTable ("TodoItem")
- async {
- do! Async.SwitchToNewThread ()
- todoTable.PurgeAsync().Wait()
- todoTable.PullAsync().Wait()
- } |> Async.StartImmediate
- printfn "yolo"
- ()
- // Return true for supported orientations
- override this.ShouldAutorotateToInterfaceOrientation (orientation) =
- true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement