CmisSync.Lib.Accumulator.RemoteObjectFetcher.Handle C# (CSharp) Метод

Handle() публичный Метод

Handles the specified e.
public Handle ( ISyncEvent e ) : bool
e ISyncEvent sync events
Результат bool
        public override bool Handle(ISyncEvent e) {
            if (!(e is FileEvent || e is FolderEvent || e is CrawlRequestEvent)) {
                return false;
            }

            ICmisObject remote = this.GetRemoteObject(e);

            // already there, no need to GetObject
            if (remote != null) {
                return false;
            }

            string id;
            if (e is AbstractFolderEvent && (e as AbstractFolderEvent).Local == MetaDataChangeType.DELETED) {
                id = this.FetchIdFromStorage(e);
            } else {
                id = this.FetchIdFromExtendedAttribute(e);
            }

            if (id != null) {
                Logger.Debug("Fetching remote Object with id " + id);
                try {
                    remote = this.session.GetObject(id, this.operationContext);
                    Logger.Debug("Fetched object " + remote);
                } catch (CmisObjectNotFoundException) {
                    Logger.Debug("Was already deleted on server, could not fetch");
                    return false;
                }

                this.SetRemoteObject(e, remote);
            }

            return false;
        }

Usage Example

        public void DoNotFetchIfExtendedAttributeIsMissing() {
            var session = new Mock<ISession>();
            session.SetupSessionDefaultValues();
            IDocument remote = MockOfIDocumentUtil.CreateRemoteDocumentMock(null, Id, "name", (string)null).Object;
            session.Setup(s => s.GetObject(Id, It.IsAny<IOperationContext>())).Returns(remote);

            var storage = new Mock<IMetaDataStorage>();
            storage.AddLocalFile(Path, Id, Uuid);

            var fileEvent = new FileEvent(Mock.Of<IFileInfo>());
            var fetcher = new RemoteObjectFetcher(session.Object, storage.Object);
            fetcher.Handle(fileEvent);

            session.Verify(s => s.GetObject(It.IsAny<string>(), It.IsAny<IOperationContext>()), Times.Never());
        }
All Usage Examples Of CmisSync.Lib.Accumulator.RemoteObjectFetcher::Handle