Exemple #1
0
        /// <summary>
        /// Verifies if an item supports transforms.
        /// </summary>
        /// <param name="project">Current IVsProject</param>
        /// <param name="itemid">Id of the item inside the project</param>
        /// <returns>True if the item supports transforms</returns>
        private bool ItemSupportsTransforms(IVsProject project, uint itemid)
        {
            if (ErrorHandler.Failed(project.GetMkDocument(itemid, out string itemFullPath)))
            {
                return(false);
            }

            if (!PackageUtilities.IsExtensionSupportedForFile(itemFullPath))
            {
                return(false);
            }

            if (!this.package.IsItemTransformItem(project, itemid))
            {
                return(false);
            }

            // web.config has its own transform support
            if (string.Compare("web.config", Path.GetFileName(itemFullPath), StringComparison.OrdinalIgnoreCase) == 0)
            {
                return(false);
            }

            // All quick checks done, ask if this is any transformer supports this.
            // This may hit the disk, which is costly for a context menu check and preferably avoided.
            return(TransformerFactory.IsSupportedFile(itemFullPath));
        }
Exemple #2
0
        /// <summary>
        /// Verifies if an item supports transforms.
        /// </summary>
        /// <param name="project">Current IVsProject</param>
        /// <param name="itemid">Id of the item inside the project</param>
        /// <returns>True if the item supports transforms</returns>
        private bool ItemSupportsTransforms(IVsProject project, uint itemid)
        {
            if (ErrorHandler.Failed(project.GetMkDocument(itemid, out string itemFullPath)))
            {
                return(false);
            }

            bool     itemSupportsTransforms = false;
            FileInfo transformFileInfo      = new FileInfo(itemFullPath);

            // make sure its not a transform file itself
            bool isWebConfig                 = string.Compare("web.config", transformFileInfo.Name, StringComparison.OrdinalIgnoreCase) == 0;
            bool isTransformFile             = this.IsItemTransformItem(project, itemid);
            bool isExtensionSupportedForFile = PackageUtilities.IsExtensionSupportedForFile(itemFullPath);
            bool isXmlFile = PackageUtilities.IsXmlFile(itemFullPath);

            if (!isWebConfig && !isTransformFile && isExtensionSupportedForFile && isXmlFile)
            {
                itemSupportsTransforms = true;
            }

            return(itemSupportsTransforms);
        }