public override bool AddSourceCode(CodeProject project, string path, object context) { Param.RequireNotNull(project, "project"); Param.RequireValidString(path, "path"); bool flag = false; string extension = Path.GetExtension(path); if ((extension != null) && (extension.Length > 0)) { extension = extension.Substring(1).ToUpperInvariant(); ICollection<SourceParser> parsersForFileType = this.GetParsersForFileType(extension); if (parsersForFileType == null) { return flag; } foreach (SourceParser parser in parsersForFileType) { SourceCode sourceCode = this.CreateCodeFile(path, project, parser, context); project.AddSourceCode(sourceCode); flag = true; } } return flag; }
/// <summary> /// Adds a source code document to the given project. /// </summary> /// <param name="project">The project which should contain the source code instance.</param> /// <param name="path">The path to the source code document to add.</param> /// <param name="context">Optional context information.</param> /// <returns>Returns true if any source code documents were added to the project.</returns> public override bool AddSourceCode(CodeProject project, string path, object context) { Param.RequireNotNull(project, "project"); Param.RequireValidString(path, "path"); Param.Ignore(context); bool added = false; // Get the parsers for this file based on its extension. string extension = Path.GetExtension(path); if (extension != null && extension.Length > 0) { // Remove the leading dot and convert the extension to lower-case. extension = extension.Substring(1).ToUpperInvariant(); ICollection<SourceParser> parserList = this.GetParsersForFileType(extension); if (parserList != null) { // Create SourceCode objects representing this file, for each parser. foreach (SourceParser parser in parserList) { // Create and return a SourceCode for this file. SourceCode source = this.CreateCodeFile(path, project, parser, context); project.AddSourceCode(source); added = true; } } } return added; }