public string FlushText(Project project) { _buffer = new StringBuilder(); foreach (ProjectItem item in ProjectHelper.EnumerateCSharpFiles(project.ProjectItems)) { _buffer.AppendFormat("文件:{0}", item.Name); _buffer.AppendLine(); _level++; this.Visit(item.FileCodeModel.CodeElements); _level--; } //如果使用 project.CodeModel 来进行遍历,则会包含所有涉及到的类型。 //这些类型甚至包括 Rafy、Microsoft、System 等命名空间中的大量类型。 //var elements = project.CodeModel.CodeElements; //this.Visit(elements); var res = _buffer.ToString(); File.WriteAllText(@"D:\TextVisitorResult.txt", res); return(res); }
/// <summary> /// 读取整个项目的实体类结构 /// </summary> /// <param name="project"></param> public void ReadProject(Project project) { Reset(project); //对所有 CSharp 文件进行解析。 foreach (var item in ProjectHelper.EnumerateCSharpFiles(project.ProjectItems)) { this.Visit(item.FileCodeModel.CodeElements); } AddRelations(); }
public ProjectItem FindClassFile(Project project, string classFullName) { _result = null; _classFullName = classFullName; //对所有 CSharp 文件进行解析。 foreach (var item in ProjectHelper.EnumerateCSharpFiles(project.ProjectItems)) { this.Visit(item.FileCodeModel.CodeElements); } return(_result); }
void ModelingEditor_Drop(object sender, DragEventArgs e) { var fileName = e.Data.GetData(typeof(string)) as string; var items = _owner.Project.ProjectItems; foreach (ProjectItem item in ProjectHelper.EnumerateCSharpFiles(items)) { var itemFileName = item.get_FileNames(0); if (itemFileName == fileName) { OnItemDropped(item); break; } } e.Handled = true; }