Esempio n. 1
0
        /// <summary>
        ///     Some comments are shown collapsed, non-full.
        ///     This function replaces them in the tree with full
        ///     versions that were downloaded specifically.
        ///     We also update text if it was edited to larger text.
        /// </summary>
        /// <param name="needUpdate">Initial comment.</param>
        /// <param name="source">Full version of the same comment.</param>
        /// <returns>Updated or not.</returns>
        public bool UpdateDirectDataWith(Comment target, Comment source)
        {
            bool updated = false;

            if (source == null || target == null)
            {
                throw new ArgumentNullException();
            }

            if (!source.IsFull || source.IsDeleted)
            {
                return(false);
            }

            if (target.IsFull == false)
            {
                target.IsFull = true;
                updated       = true;
            }

            // General data.
            updated |= _ebh.UpdateWith(target, source);

            updated |= _ebh.UpdateStringProperty(source.ParentUrl, target.ParentUrl, s => target.ParentUrl = s);

            if (target.Poster == null && source.Poster != null)
            {
                target.Poster = source.Poster;
                updated       = true;
            }

            return(updated);
        }
        /// <summary>
        ///     Updates entry with newer information
        ///     or just puts data if it was empty.
        /// </summary>
        /// <param name="target">Entry to update.</param>
        /// <param name="source">Entry to get data from.</param>
        public bool UpdateWith(Entry target, Entry source)
        {
            log.DebugFormat("Merging entry {0} with another source.", target);

            bool updated = false;

            if (target == null || source == null)
            {
                throw new ArgumentNullException();
            }

            updated |= _ebh.UpdateWith(target, source);

            updated |= _ebh.UpdateStringProperty(source.NextUrl, target.NextUrl, s => target.NextUrl = s);
            updated |= _ebh.UpdateStringProperty(source.PreviousUrl, target.PreviousUrl, s => target.PreviousUrl = s);

            return(updated);
        }