/// <summary> /// Retrieves the configuration dependent property pages. /// </summary> /// <param name="pages">The pages to return.</param> private void GetCfgPropertyPages(CAUUID[] pages) { // We do not check whether the supportsProjectDesigner is set to true on the ProjectNode. // We rely that the caller knows what to call on us. if (pages == null) { throw new ArgumentNullException("pages"); } if (pages.Length == 0) { throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "pages"); } // Retrive the list of guids from hierarchy properties. // Because a flavor could modify that list we must make sure we are calling the outer most implementation of IVsHierarchy string guidsList = String.Empty; IVsHierarchy hierarchy = HierarchyNode.GetOuterHierarchy(this.project); object variant = null; ErrorHandler.ThrowOnFailure(hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID2.VSHPROPID_CfgPropertyPagesCLSIDList, out variant), new int[] { VSConstants.DISP_E_MEMBERNOTFOUND, VSConstants.E_NOTIMPL }); guidsList = (string)variant; Guid[] guids = Utilities.GuidsArrayFromSemicolonDelimitedStringOfGuids(guidsList); if (guids == null || guids.Length == 0) { pages[0] = new CAUUID(); pages[0].cElems = 0; } else { pages[0] = PackageUtilities.CreateCAUUIDFromGuidArray(guids); } }
/// <summary> /// Maps back to the hierarchy or project item object corresponding to the browse object. /// </summary> /// <param name="hier">Reference to the hierarchy object.</param> /// <param name="itemid">Reference to the project item.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public virtual int GetProjectItem(out IVsHierarchy hier, out uint itemid) { Utilities.CheckNotNull(node); hier = HierarchyNode.GetOuterHierarchy(this.node.ProjectMgr); itemid = this.node.ID; return(VSConstants.S_OK); }
object EnvDTE80.IInternalExtenderProvider.GetExtenderNames(string extenderCATID, object extendeeObject) { IVsHierarchy outerHierarchy = HierarchyNode.GetOuterHierarchy(this.Node); if (outerHierarchy is EnvDTE80.IInternalExtenderProvider) { return ((EnvDTE80.IInternalExtenderProvider)outerHierarchy).GetExtenderNames(extenderCATID, extendeeObject); } return null; }
object EnvDTE80.IInternalExtenderProvider.GetExtender(string extenderCATID, string extenderName, object extendeeObject, EnvDTE.IExtenderSite extenderSite, int cookie) { IVsHierarchy outerHierarchy = HierarchyNode.GetOuterHierarchy(this.Node); if (outerHierarchy is EnvDTE80.IInternalExtenderProvider) { return ((EnvDTE80.IInternalExtenderProvider)outerHierarchy).GetExtender(extenderCATID, extenderName, extendeeObject, extenderSite, cookie); } return null; }
bool EnvDTE80.IInternalExtenderProvider.CanExtend(string extenderCATID, string extenderName, object extendeeObject) { IVsHierarchy outerHierarchy = HierarchyNode.GetOuterHierarchy(this.Node); if (outerHierarchy is EnvDTE80.IInternalExtenderProvider) { return ((EnvDTE80.IInternalExtenderProvider)outerHierarchy).CanExtend(extenderCATID, extenderName, extendeeObject); } return false; }
object EnvDTE80.IInternalExtenderProvider.GetExtenderNames(string extenderCATID, object extendeeObject) { IVsHierarchy lVsHierarchy = HierarchyNode.GetOuterHierarchy(this.ProjectMgr); if (lVsHierarchy is EnvDTE80.IInternalExtenderProvider) { return(((EnvDTE80.IInternalExtenderProvider)lVsHierarchy).GetExtenderNames(extenderCATID, extendeeObject)); } return(null); }
/// <summary> /// Maps back to the hierarchy or project item object corresponding to the browse object. /// </summary> /// <param name="hier">Reference to the hierarchy object.</param> /// <param name="itemid">Reference to the project item.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns> public virtual int GetProjectItem(out IVsHierarchy hier, out uint itemid) { if (this.node == null) { throw new InvalidOperationException(); } hier = HierarchyNode.GetOuterHierarchy(this.node.ProjectMgr); itemid = this.node.ID; return(VSConstants.S_OK); }
bool EnvDTE80.IInternalExtenderProvider.CanExtend(string extenderCATID, string extenderName, object extendeeObject) { IVsHierarchy lVsHierarchy = HierarchyNode.GetOuterHierarchy(this.ProjectMgr); if (lVsHierarchy is EnvDTE80.IInternalExtenderProvider) { return(((EnvDTE80.IInternalExtenderProvider)lVsHierarchy).CanExtend(extenderCATID, extenderName, extendeeObject)); } return(false); }
object EnvDTE80.IInternalExtenderProvider.GetExtenderNames(string extenderCATID, object extendeeObject) { EnvDTE80.IInternalExtenderProvider outerHierarchy = HierarchyNode.GetOuterHierarchy(this.Node) as EnvDTE80.IInternalExtenderProvider; if (outerHierarchy != null) { return(outerHierarchy.GetExtenderNames(extenderCATID, extendeeObject)); } return(null); }
object EnvDTE80.IInternalExtenderProvider.GetExtender(string extenderCATID, string extenderName, object extendeeObject, EnvDTE.IExtenderSite extenderSite, int cookie) { EnvDTE80.IInternalExtenderProvider outerHierarchy = HierarchyNode.GetOuterHierarchy(this.Node) as EnvDTE80.IInternalExtenderProvider; if (outerHierarchy != null) { return(outerHierarchy.GetExtender(extenderCATID, extenderName, extendeeObject, extenderSite, cookie)); } return(null); }
bool EnvDTE80.IInternalExtenderProvider.CanExtend(string extenderCATID, string extenderName, object extendeeObject) { EnvDTE80.IInternalExtenderProvider outerHierarchy = HierarchyNode.GetOuterHierarchy(this.Node) as EnvDTE80.IInternalExtenderProvider; if (outerHierarchy != null) { return(outerHierarchy.CanExtend(extenderCATID, extenderName, extendeeObject)); } return(false); }
object EnvDTE80.IInternalExtenderProvider.GetExtenderNames(string extenderCATID, object extendeeObject) { ThreadHelper.ThrowIfNotOnUIThread(); IVsHierarchy outerHierarchy = HierarchyNode.GetOuterHierarchy(this.Node); if (outerHierarchy is EnvDTE80.IInternalExtenderProvider) { return(((EnvDTE80.IInternalExtenderProvider)outerHierarchy).GetExtenderNames(extenderCATID, extendeeObject)); } return(null); }
object EnvDTE80.IInternalExtenderProvider.GetExtender(string extenderCATID, string extenderName, object extendeeObject, EnvDTE.IExtenderSite extenderSite, int cookie) { ThreadHelper.ThrowIfNotOnUIThread(); IVsHierarchy outerHierarchy = HierarchyNode.GetOuterHierarchy(this.Node); if (outerHierarchy is EnvDTE80.IInternalExtenderProvider) { return(((EnvDTE80.IInternalExtenderProvider)outerHierarchy).GetExtender(extenderCATID, extenderName, extendeeObject, extenderSite, cookie)); } return(null); }
public object GetExtenderNames(string ExtenderCATID, object ExtendeeObject) { IVsHierarchy outerHierarchy = HierarchyNode.GetOuterHierarchy(ProjectMgr); if (outerHierarchy is IInternalExtenderProvider) { return(((IInternalExtenderProvider)outerHierarchy).GetExtenderNames(ExtenderCATID, ExtendeeObject)); } return(null); }
public object GetExtender(string ExtenderCATID, string ExtenderName, object ExtendeeObject, IExtenderSite ExtenderSite, int Cookie) { IVsHierarchy outerHierarchy = HierarchyNode.GetOuterHierarchy(ProjectMgr); if (outerHierarchy is IInternalExtenderProvider) { return(((IInternalExtenderProvider)outerHierarchy).GetExtender( ExtenderCATID, ExtenderName, ExtendeeObject, ExtenderSite, Cookie)); } return(null); }
public bool CanExtend(string ExtenderCATID, string ExtenderName, object ExtendeeObject) { // IVsHierarchy outerHierarchy = HierarchyNode.GetOuterHierarchy(ProjectMgr); if (outerHierarchy is IInternalExtenderProvider) { return(((IInternalExtenderProvider)outerHierarchy).CanExtend( ExtenderCATID, ExtenderName, ExtendeeObject)); } return(false); }
/// <summary> /// Retrieves the common property pages. The NodeProperties is the BrowseObject and that will be called to support /// configuration independent properties. /// </summary> /// <param name="pages">The pages to return.</param> private void GetCommonPropertyPages(CAUUID[] pages) { // We do not check whether the supportsProjectDesigner is set to false on the ProjectNode. // We rely that the caller knows what to call on us. Debug.Assert(this.node != null, "The associated hierarchy node has not been initialized"); if (pages == null) { throw new ArgumentNullException("pages"); } if (pages.Length == 0) { throw new ArgumentException(SR.GetString(SR.InvalidParameter), "pages"); } // Only the project should show the property page the rest should show the project properties. if (this.node != null && (this.node is ProjectNode)) { // Retrive the list of guids from hierarchy properties. // Because a flavor could modify that list we must make sure we are calling the outer most implementation of IVsHierarchy string guidsList = String.Empty; IVsHierarchy hierarchy = HierarchyNode.GetOuterHierarchy(this.Node.ProjectMgr); object variant = null; ErrorHandler.ThrowOnFailure(hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID2.VSHPROPID_PropertyPagesCLSIDList, out variant)); guidsList = (string)variant; Guid[] guids = Utilities.GuidsArrayFromSemicolonDelimitedStringOfGuids(guidsList); if (guids == null || guids.Length == 0) { pages[0] = new CAUUID(); pages[0].cElems = 0; } else { pages[0] = PackageUtilities.CreateCAUUIDFromGuidArray(guids); } } else { pages[0] = new CAUUID(); pages[0].cElems = 0; } }
/// <summary> /// Saves or Save Asthe project. /// </summary> /// <param name="isCalledFromSaveAs">Flag determining which Save method called , the SaveAs or the Save.</param> /// <param name="fileName">The name of the project file.</param> private void DoSave(bool isCalledFromSaveAs, string fileName) { if (fileName == null) { throw new ArgumentNullException("fileName"); } if (this.project == null || this.project.Site == null || this.project.IsClosed) { throw new InvalidOperationException(); } using (AutomationScope scope = new AutomationScope(this.project.Site)) { // If an empty file name is passed in for Save then make the file name the project name. if (!isCalledFromSaveAs && string.IsNullOrEmpty(fileName)) { // Use the solution service to save the project file. Note that we have to use the service // so that all the shell's elements are aware that we are inside a save operation and // all the file change listenters registered by the shell are suspended. // Get the cookie of the project file from the RTD. IVsRunningDocumentTable rdt = this.project.Site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; if (null == rdt) { throw new InvalidOperationException(); } IVsHierarchy hier; uint itemid; IntPtr unkData; uint cookie; ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, this.project.Url, out hier, out itemid, out unkData, out cookie)); if (IntPtr.Zero != unkData) { Marshal.Release(unkData); } // Verify that we have a cookie. if (0 == cookie) { // This should never happen because if the project is open, then it must be in the RDT. throw new InvalidOperationException(); } // Get the IVsHierarchy for the project. IVsHierarchy prjHierarchy = HierarchyNode.GetOuterHierarchy(this.project); // Now get the soulution. IVsSolution solution = this.project.Site.GetService(typeof(SVsSolution)) as IVsSolution; // Verify that we have both solution and hierarchy. if ((null == prjHierarchy) || (null == solution)) { throw new InvalidOperationException(); } ErrorHandler.ThrowOnFailure(solution.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_SaveIfDirty, prjHierarchy, cookie)); } else { // We need to make some checks before we can call the save method on the project node. // This is mainly because it is now us and not the caller like in case of SaveAs or Save that should validate the file name. // The IPersistFileFormat.Save method only does a validation that is necesseray to be performed. Example: in case of Save As the // file name itself is not validated only the whole path. (thus a file name like file\file is accepted, since as a path is valid) // 1. The file name has to be valid. string fullPath = fileName; try { if (!Path.IsPathRooted(fileName)) { fullPath = Path.Combine(this.project.ProjectFolder, fileName); } } // We want to be consistent in the error message and exception we throw. fileName could be for example #¤&%"¤&"% and that would trigger an ArgumentException on Path.IsRooted. catch (ArgumentException) { throw new InvalidOperationException(SR.GetString(SR.ErrorInvalidFileName, CultureInfo.CurrentUICulture)); } // It might be redundant but we validate the file and the full path of the file being valid. The SaveAs would also validate the path. // If we decide that this is performance critical then this should be refactored. Utilities.ValidateFileName(this.project.Site, fullPath); if (!isCalledFromSaveAs) { // 2. The file name has to be the same if (!NativeMethods.IsSamePath(fullPath, this.project.Url)) { throw new InvalidOperationException(); } ErrorHandler.ThrowOnFailure(this.project.Save(fullPath, 1, 0)); } else { ErrorHandler.ThrowOnFailure(this.project.Save(fullPath, 0, 0)); } } } }