Ejemplo n.º 1
0
        /// <summary>
        /// Watches the child folder.
        /// </summary>
        /// <param name="child">The child folder. Ownership will be taken.</param>
        private void WatchChild(IFolder child, bool takeOwnership)
        {
            if (!_children.ContainsKey(child.EntryID))
            {
                if (_watcher.ShouldFolderBeWatched(this, child))
                {
                    Logger.Instance.Trace(this, "Registering child on {0}: {1}", _folder.LogKey, child.FullFolderPath);

                    // Make sure we register the entry id actually before registering any listeners.
                    // That will cause change notifications, which require the entryid to be registered.
                    IFolder     childEffective = takeOwnership ? child : child.Clone();
                    ZPushFolder folder         = new ZPushFolder(_watcher, this, childEffective);
                    _children.Add(child.EntryID, folder);
                    folder.Initialise();
                    return;
                }
                else
                {
                    Logger.Instance.Trace(this, "Excluding child on {0}: {1}", _folder.LogKey, child.FullFolderPath);
                }
            }

            if (takeOwnership)
            {
                // Release the folder if not used
                child.Dispose();
            }
        }