コード例 #1
0
        public void EnumerateChanges(INSFileProviderChangeObserver observer, NSData syncAnchor)
        {
            try
            {
                FileMetadata metadata = storageManager.GetFileMetadata(this.EnumeratedItemIdentifier);
                if (!metadata.IsExists)
                {
                    observer.DidDeleteItems(new[] { EnumeratedItemIdentifier });
                    observer.FinishEnumeratingChanges(this.GetNsDataFromUint(this.SyncAnchor++), false);
                    return;
                }

                observer.DidUpdateItems(new[] { ProviderItem.CreateFromMetadata(metadata) });
                observer.FinishEnumeratingChanges(this.GetNsDataFromUint(this.SyncAnchor++), false);
            }
            catch (UnauthorizedException)
            {
                observer.FinishEnumerating(NSFileProviderErrorFactory.CreatesNotAuthenticatedError());
            }
            catch (WebDavHttpException)
            {
                observer.FinishEnumerating(NSErrorFactory.CreateUnspecifiedNetworkError());
            }
            catch (Exception)
            {
                observer.FinishEnumerating(NSErrorFactory.CreateUnspecifiedError());
            }
        }
コード例 #2
0
        public void EnumerateChanges(INSFileProviderChangeObserver observer, NSData syncAnchor)
        {
            uint anchor = GetAnchorFromNsData(syncAnchor);

            try
            {
                FolderMetadata metadata = storageManager.GetFolderMetadata(this.enumeratedItemIdentifier);
                if (!metadata.IsExists)
                {
                    observer.FinishEnumerating(NSFileProviderErrorFactory.CreateNonExistentItemError(enumeratedItemIdentifier));
                    return;
                }

                ItemMetadata[] metadatas = this.storageManager.GetFolderChildrenMetadatas(metadata);
                ChangeSet      diff      = this.synchronizationSimulator.GetDiff(anchor, metadatas);
                observer.DidDeleteItems(diff.DeletedId);
                INSFileProviderItem[] updatedItems = ProviderItem.CreateFromMetadatas(diff.Updated);
                observer.DidUpdateItems(updatedItems);

                this.SyncAnchor = this.synchronizationSimulator.AddChangeSet(metadatas);
                observer.FinishEnumeratingChanges(this.GetCurrentAnchorNsData(this.SyncAnchor), false);
            }
            catch (UnauthorizedException)
            {
                observer.FinishEnumerating(NSFileProviderErrorFactory.CreatesNotAuthenticatedError());
            }
            catch (WebDavHttpException)
            {
                observer.FinishEnumerating(NSErrorFactory.CreateUnspecifiedNetworkError());
            }
            catch (Exception)
            {
                observer.FinishEnumerating(NSErrorFactory.CreateUnspecifiedError());
            }
        }