CmisSync.Lib.SelectiveIgnore.IgnoreFlagChangeDetection.Handle C# (CSharp) Method

Handle() public method

Observes content change events and if they effect exiting entries, updates to storage are executed. If an existing entry is not ignored anymore a crawl sync is started.
public Handle ( ISyncEvent e ) : bool
e ISyncEvent The content change events to be observed.
return bool
        public override bool Handle(ISyncEvent e) {
            if (e is ContentChangeEvent) {
                var change = e as ContentChangeEvent;
                if (change.Type == DotCMIS.Enums.ChangeType.Deleted) {
                    if (this.ignores.IsIgnoredId(change.ObjectId) == IgnoredState.IGNORED) {
                        this.ignores.Remove(change.ObjectId);
                        this.Queue.AddEvent(new StartNextSyncEvent(true));
                    }

                    return false;
                }

                switch (this.ignores.IsIgnoredId(change.ObjectId)) {
                case IgnoredState.IGNORED:
                    if (!change.CmisObject.AreAllChildrenIgnored()) {
                        this.ignores.Remove(change.ObjectId);
                        this.Queue.AddEvent(new StartNextSyncEvent(true));
                    }

                    break;
                case IgnoredState.INHERITED:
                    goto case IgnoredState.NOT_IGNORED;
                case IgnoredState.NOT_IGNORED:
                    if (change.CmisObject.AreAllChildrenIgnored()) {
                        if (change.CmisObject is IFolder) {
                            this.ignores.AddOrUpdateEntryAndDeleteAllChildrenFromStorage(new IgnoredEntity(change.CmisObject as IFolder, this.matcher));
                        } else if (change.CmisObject is IDocument) {
                            this.ignores.Add(new IgnoredEntity(change.CmisObject as IDocument, this.matcher));
                        }
                    }

                    break;
                }
            }

            return false;
        }
    }

Usage Example

 public void DetectionIgnoresNonContentChangeEvents() {
     this.SetUpMocks();
     var underTest = new IgnoreFlagChangeDetection(this.ignoreStorage.Object, this.matcher.Object, this.queue.Object);
     Assert.That(underTest.Handle(Mock.Of<ISyncEvent>()), Is.False);
 }
IgnoreFlagChangeDetection