/// <summary>
        ///     Gets the value of the layout field from the base layout if one is selected.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>The merged layout field value of the base layout chain.</returns>
        public virtual string GetBaseLayoutValue(Item item)
        {
            // Get the item selected in the Base Layout field.  Otherwise, exit.
            var baseLayout = new BaseLayoutItem(item).BaseLayout;
            if (baseLayout == null)
            {
                return null;
            }

            // Get the value of the layout field on the base layout.
            // If the selected item also has a base layout selected, this will cause implicit recursion.
            return new LayoutField(baseLayout).Value;
        }
        /// <summary>
        ///     Gets the value of the layout field from the base layout if one is selected.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>The merged layout field value of the base layout chain.</returns>
        public virtual string GetBaseLayoutValue(Item item)
        {
            // Get the item selected in the Base Layout field.  Otherwise, exit.
            var baseLayout = new BaseLayoutItem(item).BaseLayout;

            if (baseLayout == null)
            {
                return(null);
            }

            // Get the value of the layout field on the base layout.
            // If the selected item also has a base layout selected, this will cause implicit recursion.
            return(new LayoutField(baseLayout).Value);
        }
        /// <summary>
        ///     Determines if there are duplicat IDs in the baseLayouts ID set and the chain of base layout IDs originating at
        ///     item.
        /// </summary>
        /// <param name="item">the item</param>
        /// <param name="baseLayouts">the starting set of IDs</param>
        /// <returns>True if there are duplicate IDs.  False if not.</returns>
        protected virtual bool HasDuplicateBaseLayout(BaseLayoutItem item, HashSet<ID> baseLayouts)
        {
            var item2 = item;
            do
            {
                if (!baseLayouts.Add(item2.ID))
                {
                    return true;
                }

                item2 = item2.BaseLayout;
            } while (item2 != null);

            return false;
        }
        /// <summary>
        ///     Determines if there are duplicat IDs in the baseLayouts ID set and the chain of base layout IDs originating at
        ///     item.
        /// </summary>
        /// <param name="item">the item</param>
        /// <param name="baseLayouts">the starting set of IDs</param>
        /// <returns>True if there are duplicate IDs.  False if not.</returns>
        protected virtual bool HasDuplicateBaseLayout(BaseLayoutItem item, HashSet <ID> baseLayouts)
        {
            var item2 = item;

            do
            {
                if (!baseLayouts.Add(item2.ID))
                {
                    return(true);
                }

                item2 = item2.BaseLayout;
            } while (item2 != null);

            return(false);
        }
 /// <summary>
 ///     Initializes an instance of SaveBaseLayoutArgs
 /// </summary>
 /// <param name="item">the item to be saved</param>
 public SaveBaseLayoutArgs(BaseLayoutItem item)
 {
     Assert.ArgumentNotNull(item, "item");
     Item = item;
     OldBaseLayoutItem = item.BaseLayout;
 }