Esempio n. 1
0
        internal MobileServiceFileSyncContext(IMobileServiceClient client, IFileMetadataStore metadataStore, IFileOperationQueue operationsQueue,
                                              IFileSyncTriggerFactory syncTriggerFactory, IFileSyncHandler syncHandler, IMobileServiceFilesClient filesClient)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            if (metadataStore == null)
            {
                throw new ArgumentNullException("metadataStore");
            }

            if (operationsQueue == null)
            {
                throw new ArgumentNullException("operationsQueue");
            }

            if (syncTriggerFactory == null)
            {
                throw new ArgumentNullException("syncTriggerFactory");
            }

            if (syncHandler == null)
            {
                throw new ArgumentNullException("syncHandler");
            }

            this.metadataStore            = metadataStore;
            this.syncHandler              = syncHandler;
            this.operationsQueue          = operationsQueue;
            this.mobileServiceFilesClient = filesClient ?? new MobileServiceFilesClient(client, new AzureBlobStorageProvider(client));
            this.eventManager             = client.EventManager;
            this.triggers = syncTriggerFactory.CreateTriggers(this);
        }
        internal MobileServiceFileSyncContext(IMobileServiceClient client, IFileMetadataStore metadataStore, IFileOperationQueue operationsQueue, 
            IFileSyncTriggerFactory syncTriggerFactory, IFileSyncHandler syncHandler, IMobileServiceFilesClient filesClient)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            if (metadataStore == null)
            {
                throw new ArgumentNullException("metadataStore");
            }

            if (operationsQueue == null)
            {
                throw new ArgumentNullException("operationsQueue");
            }

            if (syncTriggerFactory == null)
            {
                throw new ArgumentNullException("syncTriggerFactory");
            }

            if (syncHandler == null)
            {
                throw new ArgumentNullException("syncHandler");
            }

            this.metadataStore = metadataStore;
            this.syncHandler = syncHandler;
            this.operationsQueue = operationsQueue;
            this.mobileServiceFilesClient = filesClient ?? new MobileServiceFilesClient(client, new AzureBlobStorageProvider(client));
            this.eventManager = client.EventManager;
            this.triggers = syncTriggerFactory.CreateTriggers(this);
        }
        /// <summary>
        /// Initializes the file synchronization capabilities of the <see cref="IMobileServiceClient"/>. Offline sync must also be initialized by calling
        /// IMobileServiceClient.SyncContext.InitializeAsync.
        /// </summary>
        /// <param name="client">IMobileServiceClient instance</param>
        /// <param name="syncHandler">An instance of <see cref="IFileSyncHandler"/> that specifies how to handle changes to stored files</param>
        /// <returns>An instance of <see cref="IFileSyncContext"/></returns>
        public static IFileSyncContext InitializeFileSyncContext(this IMobileServiceClient client, IFileSyncHandler syncHandler)
        {
            if (!client.SyncContext.IsInitialized)
            {
                throw new InvalidOperationException(@"The file sync context cannot be initialized without a MobileServiceLocalStore if offline sync has not been initialized. 
Please initialize offline sync by invoking InitializeAsync on the SyncContext or provide an IMobileServiceLocalStore instance to the InitializeFileSyncContext method.");
            }

            return InitializeFileSyncContext(client, syncHandler, client.SyncContext.Store);
        }
        public static IFileSyncContext InitializeFileSyncContext(this IMobileServiceClient client, IFileSyncHandler syncHandler, IMobileServiceLocalStore store)
        {
            lock (contextsSyncRoot)
            {
                IFileSyncContext context;

                if (!contexts.TryGetValue(client, out context))
                {
                    context = new MobileServiceFileSyncContext(client, new FileMetadataStore(store), new FileOperationQueue(store), syncHandler);
                    contexts.Add(client, context);
                }

                return context;
            }
        }
Esempio n. 5
0
        public static IFileSyncContext InitializeFileSyncContext(this IMobileServiceClient client, IFileSyncHandler syncHandler,
                                                                 IMobileServiceLocalStore store, IFileSyncTriggerFactory fileSyncTriggerFactory)
        {
            lock (contextsSyncRoot)
            {
                IFileSyncContext context;

                if (!contexts.TryGetValue(client, out context))
                {
                    context = new MobileServiceFileSyncContext(client, new FileMetadataStore(store), new FileOperationQueue(store), fileSyncTriggerFactory, syncHandler);
                    contexts.Add(client, context);
                }

                return(context);
            }
        }
Esempio n. 6
0
 public static IFileSyncContext InitializeFileSyncContext(this IMobileServiceClient client, IFileSyncHandler syncHandler, IMobileServiceLocalStore store)
 {
     return(InitializeFileSyncContext(client, syncHandler, store, new DefaultFileSyncTriggerFactory(client, true)));
 }
Esempio n. 7
0
        public static IFileSyncContext InitializeFileSyncContext(this IMobileServiceClient client, IFileSyncHandler syncHandler)
        {
            if (!client.SyncContext.IsInitialized)
            {
                throw new InvalidOperationException(@"The file sync context cannot be initialized without a MobileServiceLocalStore if offline sync has not been initialized. 
Please initialize offline sync by invoking InializeAsync on the sync context or provide an IMobileServiceLocalStore instance to the InitializeFileSyncContext method.");
            }

            return(InitializeFileSyncContext(client, syncHandler, client.SyncContext.Store));
        }
Esempio n. 8
0
 public MobileServiceFileSyncContext(IMobileServiceClient client, IFileMetadataStore metadataStore, IFileOperationQueue operationsQueue,
                                     IFileSyncTriggerFactory syncTriggerFactory, IFileSyncHandler syncHandler)
     : this(client, metadataStore, operationsQueue, syncTriggerFactory, syncHandler, null)
 {
 }
 /// <summary>
 /// Initializes the file synchronization capabilities of the <see cref="IMobileServiceClient"/>. Offline sync must also be initialized by calling
 /// IMobileServiceClient.SyncContext.InitializeAsync.
 /// </summary>
 /// <param name="client">IMobileServiceClient instance</param>
 /// <param name="syncHandler">An instance of <see cref="IFileSyncHandler"/> that specifies how to handle changes to stored files</param>
 /// <param name="store">The <see cref="IMobileServiceLocalStore"/> for storing file metadata locally</param>
 /// <param name="fileSyncTriggerFactory">An instance of <see cref="IFileSyncTriggerFactory"/> that generates <see cref="IFileSyncTrigger"/> objects for triggering synchronisation of file metadata and content</param>
 /// <returns>An instance of <see cref="IFileSyncContext"/></returns>
 public static IFileSyncContext InitializeFileSyncContext(this IMobileServiceClient client, IFileSyncHandler syncHandler, IMobileServiceLocalStore store, IFileSyncTriggerFactory fileSyncTriggerFactory)
 {
     return client.InitializeFileSyncContext(new MobileServiceFileSyncContext(client, new FileMetadataStore(store), new FileOperationQueue(store), fileSyncTriggerFactory, syncHandler));
 }
 /// <summary>
 /// Initializes the file synchronization capabilities of the <see cref="IMobileServiceClient"/>. Offline sync must also be initialized by calling
 /// IMobileServiceClient.SyncContext.InitializeAsync.
 /// </summary>
 /// <param name="client">IMobileServiceClient instance</param>
 /// <param name="syncHandler">An instance of <see cref="IFileSyncHandler"/> that specifies how to handle changes to stored files</param>
 /// <param name="store">The <see cref="IMobileServiceLocalStore"/> for storing file metadata locally</param>
 /// <returns>An instance of <see cref="IFileSyncContext"/></returns>
 public static IFileSyncContext InitializeFileSyncContext(this IMobileServiceClient client, IFileSyncHandler syncHandler, IMobileServiceLocalStore store)
 {
     return InitializeFileSyncContext(client, syncHandler, store, new DefaultFileSyncTriggerFactory(client, true));
 }
 internal static void InitializeFileSync(IFileSyncHandler handler)
 {
     fileSyncHandler = handler;
 }
 public MobileServiceExpressFileSyncContext(IMobileServiceClient client, IFileMetadataStore metadataStore, IFileOperationQueue operationsQueue,
     IFileSyncTriggerFactory syncTriggerFactory, IFileSyncHandler syncHandler, IMobileServiceFilesClient filesClient, ILocalStorageProvider localStorage) 
     : base(client, metadataStore, operationsQueue, syncTriggerFactory, syncHandler, filesClient)
 {
     LocalStorage = localStorage;
 }
 public MobileServiceFileSyncContext(IMobileServiceClient client, IFileMetadataStore metadataStore, IFileOperationQueue operationsQueue,
     IFileSyncTriggerFactory syncTriggerFactory, IFileSyncHandler syncHandler)
     : this(client, metadataStore, operationsQueue, syncTriggerFactory, syncHandler, null)
 { }