コード例 #1
0
 /// <summary>
 /// Gets the language properties for the specified file.
 /// </summary>
 /// <param name="fileName">The file to get the language properties for.</param>
 /// <returns>The language properties of the specified file, or <c>null</c> if the language cannot be determined.</returns>
 public static LanguageProperties GetLanguagePropertiesForFile(string fileName)
 {
     ICSharpCode.SharpDevelop.Dom.IParser p = ResourceResolverService.GetParser(fileName);
     if (p == null)
     {
         return(null);
     }
     return(p.Language);
 }
コード例 #2
0
        /// <summary>
        /// Gets the language properties for the specified file.
        /// </summary>
        /// <param name="fileName">The file to get the language properties for.</param>
        /// <returns>The language properties of the specified file, or <c>null</c> if the language cannot be determined.</returns>
        public static LanguageProperties GetLanguagePropertiesForFile(string fileName)
        {
            var p = ResourceResolverService.GetParser(fileName);

            if (p == null)
            {
                return(null);
            }
            return(p.Language);
        }
コード例 #3
0
        protected void EnlistTestFile(string fileName, string code, bool parseFile)
        {
            ResourceResolverService.SetFileContentUnitTestOnly(fileName, code);
            ProjectFileDictionaryService.AddFile(fileName, this.Project);

            if (parseFile)
            {
                IParser parser = ResourceResolverService.GetParser(fileName);
                Assert.IsNotNull(parser, "Could not get parser for " + fileName + ".");
                ICompilationUnit cu = parser.Parse(this.DefaultProjectContent, fileName, code);
                cu.Freeze();
                Assert.IsFalse(cu.ErrorsDuringCompile, "Errors while parsing test program.");
                ParserService.RegisterParseInformation(fileName, cu);
                this.DefaultProjectContent.UpdateCompilationUnit(null, cu, fileName);
            }
        }
        // ********************************************************************************************************************************

        /// <summary>
        /// Determines whether this resolver supports resolving resources in the given file.
        /// </summary>
        /// <param name="fileName">The name of the file to examine.</param>
        /// <returns><c>true</c>, if this resolver supports resolving resources in the given file, <c>false</c> otherwise.</returns>
        public override bool SupportsFile(string fileName)
        {
            // Any parseable source code file may contain references
            if (ResourceResolverService.GetParser(fileName) != null)
            {
                return(true);
            }

            // Support additional files by extension
            switch (Path.GetExtension(fileName).ToLowerInvariant())
            {
            case ".addin":
            case ".xfrm":
            case ".xml":
                return(true);

            default:
                break;
            }

            return(false);
        }