public ProductService(IAPIConsumer api)
        {
            _api    = api;
            _client = new MobileServiceClient(api.DefaultEndPoint);
            //InitLocalStoreAsync();
            _store = new MobileServiceSQLiteStore("eshopelocaldb.db");
            _store.DefineTable <Product>();

            _client.SyncContext.InitializeAsync(_store);
            var handler = new MobileServiceSyncHandler();

            //_client.SyncContext.InitializeAsync(_store, handler, StoreTrackingOptions.None);
            _productTable = _client.GetSyncTable <Product>();
        }
Пример #2
0
        public async Task Initialize()
        {
            // verificare se il contesto di sincronizzazione è già stato sincronizzato
            if (client?.SyncContext?.IsInitialized ?? false)
            {
                return;
            }
            // inizializza client per dispositivi mobili
            client = new MobileServiceClient(Constants.ApplicationURL);
            // inizializzare il DB locale per la sincronizzazione
            var path  = Path.Combine(MobileServiceClient.DefaultDatabasePath, Constants.SyncStorePath);
            var store = new MobileServiceSQLiteStore(path);

            store.DefineTable <TodoItem>();
            // iizializza SyncContext utilizzando l'oggetto predefinito IMobileServiceSyncHandler
            var handler = new MobileServiceSyncHandler();
            await client.SyncContext.InitializeAsync(store, handler);

            todoTable = client.GetSyncTable <TodoItem>();
        }
Пример #3
0
        public async Task Initialize()
        {
            // Check if Sync Context already has been synchronized
            if (client?.SyncContext?.IsInitialized ?? false)
                return;

            // Initialize Mobile Client
            client = new MobileServiceClient(Constants.ApplicationURL);

            // Initialize local database for syncing 
            var path = Path.Combine(MobileServiceClient.DefaultDatabasePath, Constants.SyncStorePath);
            var store = new MobileServiceSQLiteStore(path);
            store.DefineTable<TodoItem>();

            //Initializes the SyncContext using the default IMobileServiceSyncHandler.
            var handler = new MobileServiceSyncHandler();
            await client.SyncContext.InitializeAsync(store, handler);

            todoTable = client.GetSyncTable<TodoItem>();
        }