Microsoft.VisualStudio.Project.NestedProjectNode.ReloadItem C# (CSharp) Method

ReloadItem() public method

Delegates the call to the inner hierarchy.
public ReloadItem ( uint reserved ) : void
reserved uint Reserved parameter defined at the IVsPersistHierarchyItem2::ReloadItem parameter.
return void
        public override void ReloadItem(uint reserved)
        {
            #region precondition
            if (this.isDisposed || this.ProjectManager == null || this.ProjectManager.IsClosed)
            {
                throw new InvalidOperationException();
            }

            Debug.Assert(this.nestedHierarchy != null, "The nested hierarchy object must be created before calling this method");
            #endregion

            IVsPersistHierarchyItem2 persistHierachyItem = this.nestedHierarchy as IVsPersistHierarchyItem2;

            // We are expecting that if we get called then the nestedhierarchy supports IVsPersistHierarchyItem2, since then hierrachy should support handling its own reload.
            // There should be no errormessage to the user since this is an internal error, that it cannot be fixed at user level.
            if (persistHierachyItem == null)
            {
                throw new InvalidOperationException();
            }

            ErrorHandler.ThrowOnFailure(persistHierachyItem.ReloadItem(VSConstants.VSITEMID_ROOT, reserved));
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Called to reload a project item.
        /// Reloads a project and its nested project nodes.
        /// </summary>
        /// <param name="itemId">Specifies itemid from VSITEMID.</param>
        /// <param name="reserved">Reserved.</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns>
        public override int ReloadItem(uint itemId, uint reserved)
        {
            #region precondition
            if (this.IsClosed)
            {
                return(VSConstants.E_FAIL);
            }
            #endregion

            NestedProjectNode node = this.NodeFromItemId(itemId) as NestedProjectNode;

            if (node != null)
            {
                object propertyAsObject = node.GetProperty((int)__VSHPROPID.VSHPROPID_HandlesOwnReload);

                if (propertyAsObject != null && (bool)propertyAsObject)
                {
                    node.ReloadItem(reserved);
                }
                else
                {
                    this.ReloadNestedProjectNode(node);
                }

                return(VSConstants.S_OK);
            }

            return(base.ReloadItem(itemId, reserved));
        }