/// <summary>Queries if this action supports the provided project item and its containing project</summary>
 /// <param name="item">Project item to query support for</param>
 /// <returns>True if the action is supported, false otherwise. This implementation supports all C# projects.</returns>
 public override bool QuerySupportForProject(EnvDTE.ProjectItem item)
 {
     if (item == null)
     {
         return(false);
     }
     return(ExtensibilityMethods.GetProjectType(item.ContainingProject) == ProjectType.CSharp && item.Document.Language.Equals("CSharp"));
 }
Exemplo n.º 2
0
 /// <summary>Queries if this action supports the provided project item and its containing project</summary>
 /// <param name="item">Project item to query support for</param>
 /// <returns>True if the action is supported, false otherwise. This implementation supports Rator (VBHTML) fiels in VB projects</returns>
 public override bool QuerySupportForProject(ProjectItem item)
 {
     if (item == null)
     {
         return(false);
     }
     return
         (ExtensibilityMethods.GetProjectType(item.ContainingProject) == ProjectType.VB &&
          item.Document.Language.Equals("HTMLX") && item.Document.Name.EndsWith(".vbhtml", StringComparison.CurrentCultureIgnoreCase));;
 }
Exemplo n.º 3
0
        /// <summary>Returns the code reference to resource specified in the parameters</summary>
        /// <param name="file">Resource file containing the resource</param>
        /// <param name="resourceName">Name of the resource</param>
        /// <param name="project">Project current file belongs to</param>
        /// <param name="string">String being extracted</param>
        /// <returns>a piece of code that would reference to the resource provided</returns>
        /// <remarks>This method does not verify if resource actually exists</remarks>
        public override string GetResourceReference(ResourceFile file, string resourceName, Project project, BaseHardCodedString @string)
        {
            string prefix = "";

            if (ExtensibilityMethods.GetProjectType(project) == ProjectType.VB)
            {
                try {
                    prefix = (string)project.Properties.Item("RootNamespace").Value;
                    if (!string.IsNullOrEmpty(prefix))
                    {
                        prefix += ".";
                    }
                } catch { }
            }

            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (String.IsNullOrEmpty(resourceName))
            {
                throw new ArgumentException(Strings.InvalidResourceName, "resourceName");
            }
            string namespacePrefix = GetNamespacePrefix(file);

            if (!file.IsDefaultResXFile())
            {
                namespacePrefix += Path.GetFileNameWithoutExtension(file.ShortFileName).Replace(' ', '_') + ".";
            }
            else
            {
                namespacePrefix += Path.GetFileNameWithoutExtension(file.FileName).Replace(' ', '_') + ".";
            }
            string reference = namespacePrefix + resourceName.Replace(' ', '_');

            return(prefix + reference);
        }
        /// <summary>Creates a new code file collection that lists all the code files in a project that can be safely edited</summary>
        /// <param name="project">Project to list code files</param>
        /// <remarks>Designer code files are not excluded</remarks>
        public CodeFileCollection(Project project) : base(project, null)
        {
            ProjectType type = ExtensibilityMethods.GetProjectType(project);

            switch (type)
            {
            case ProjectType.CSharp:
                this.codeTypeFilter = CodeType.CSharp;
                break;

            case ProjectType.VB:
                this.codeTypeFilter = CodeType.VB;
                break;

            case ProjectType.WebProject:
                this.codeTypeFilter = CodeType.Both;
                break;

            default:
                throw new ArgumentException(Strings.ProjectFileInvalid, "project");
            }
            this.FilteringMethod = new FilterMethod(this.IsValidCodeFile);
            this.RefreshListOfFiles();
        }
Exemplo n.º 5
0
 /// <summary>Queries if this action supports the provided project item and its containing project</summary>
 /// <param name="item">Project item to query support for</param>
 /// <returns>True if the action is supported, false otherwise.</returns>
 /// <remarks>This implementation supports all ASPX files and C# projects</remarks>
 public override bool QuerySupportForProject(ProjectItem item)
 {
     return(item != null && item.Document.Language.Equals("CSharp") && ExtensibilityMethods.GetProjectType(item.ContainingProject) == ProjectType.WebProject);
 }