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());
            }
        }
        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());
            }
        }
        /// <param name="observer">To be added.</param>
        /// <param name="startPage">To be added.</param>
        /// <summary>To be added.</summary>
        /// <remarks>To be added.</remarks>
        public void EnumerateItems(INSFileProviderEnumerationObserver observer, NSData startPage)
        {
            try
            {
                FolderMetadata metadata = storageManager.GetFolderMetadata(this.enumeratedItemIdentifier);
                if (!metadata.IsExists)
                {
                    observer.FinishEnumerating(NSFileProviderErrorFactory.CreateNonExistentItemError(enumeratedItemIdentifier));
                    return;
                }

                ItemMetadata[] metadatas = this.storageManager.GetFolderChildrenMetadatas(metadata);
                this.SyncAnchor = this.synchronizationSimulator.AddChangeSet(metadatas);

                INSFileProviderItem[] items = ProviderItem.CreateFromMetadatas(metadatas);
                observer.DidEnumerateItems(items);
                observer.FinishEnumerating((NSData)null);
            }
            catch (UnauthorizedException)
            {
                observer.FinishEnumerating(NSFileProviderErrorFactory.CreatesNotAuthenticatedError());
            }
            catch (WebDavHttpException)
            {
                observer.FinishEnumerating(NSErrorFactory.CreateUnspecifiedNetworkError());
            }
            catch (Exception)
            {
                observer.FinishEnumerating(NSErrorFactory.CreateUnspecifiedError());
            }
        }
示例#4
0
        private NSError MapError(Exception localFileUploadError)
        {
            switch (localFileUploadError)
            {
            case NSErrorException error:
                return(error.Error);

            case NotFoundException _:
                return(NSFileProviderErrorFactory.CreateNonExistentItemError());

            case UnauthorizedException _:
                return(NSFileProviderErrorFactory.CreatesNotAuthenticatedError());

            case WebDavHttpException _:
                return(NSErrorFactory.CreateUnspecifiedNetworkError());

            default:
                return(NSErrorFactory.CreateUnspecifiedError());
            }
        }