当前位置: 首页>>代码示例>>C#>>正文


C# IProjectContent.UpdateCompilationUnit方法代码示例

本文整理汇总了C#中IProjectContent.UpdateCompilationUnit方法的典型用法代码示例。如果您正苦于以下问题:C# IProjectContent.UpdateCompilationUnit方法的具体用法?C# IProjectContent.UpdateCompilationUnit怎么用?C# IProjectContent.UpdateCompilationUnit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProjectContent的用法示例。


在下文中一共展示了IProjectContent.UpdateCompilationUnit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildNamespace

		/// <summary>
		/// Builds Visual Basic's "My" namespace for the specified project.
		/// </summary>
		public static void BuildNamespace(VBNetProject project, IProjectContent pc)
		{
			if ("custom".Equals(project.GetEvaluatedProperty("MyType"), StringComparison.OrdinalIgnoreCase))
				return;
			
			ICompilationUnit cu = new DefaultCompilationUnit(pc);
			//cu.FileName = "GeneratedMyNamespace.vb"; // leave FileName null - fixes SD2-854
			string ns;
			if (project.RootNamespace == null || project.RootNamespace.Length == 0)
				ns = "My";
			else
				ns = project.RootNamespace + ".My";
			IClass myApp = CreateMyApplication(cu, project, ns);
			IClass myComp = CreateMyComputer(cu, ns);
			
			cu.Classes.Add(myApp);
			cu.Classes.Add(myComp);
			
			IClass myForms = null;
			if (project.OutputType == OutputType.WinExe) {
				myForms = CreateMyForms(cu, ns);
				cu.Classes.Add(myForms);
			}
			DefaultClass c = new DefaultClass(cu, ns + ".MyProject");
			c.ClassType = ClassType.Module;
			c.Modifiers = ModifierEnum.Internal | ModifierEnum.Partial | ModifierEnum.Sealed | ModifierEnum.Synthetic;
			c.Attributes.Add(new DefaultAttribute(CreateTypeRef(cu, "Microsoft.VisualBasic.HideModuleNameAttribute")));
			
			// we need to use GetClassReturnType instead of DefaultReturnType because we need
			// a reference to the compound class.
			c.Properties.Add(new DefaultProperty("Application",
			                                     new GetClassReturnType(pc, myApp.FullyQualifiedName, 0),
			                                     ModifierEnum.Public | ModifierEnum.Static,
			                                     DomRegion.Empty, DomRegion.Empty, c));
			c.Properties.Add(new DefaultProperty("Computer",
			                                     new GetClassReturnType(pc, myComp.FullyQualifiedName, 0),
			                                     ModifierEnum.Public | ModifierEnum.Static,
			                                     DomRegion.Empty, DomRegion.Empty, c));
			if (myForms != null) {
				c.Properties.Add(new DefaultProperty("Forms",
				                                     new GetClassReturnType(pc, myForms.FullyQualifiedName, 0),
				                                     ModifierEnum.Public | ModifierEnum.Static,
				                                     DomRegion.Empty, DomRegion.Empty, c));
			}
			c.Properties.Add(new DefaultProperty("User",
			                                     new GetClassReturnType(pc, "Microsoft.VisualBasic.ApplicationServices.User", 0),
			                                     ModifierEnum.Public | ModifierEnum.Static,
			                                     DomRegion.Empty, DomRegion.Empty, c));
			cu.Classes.Add(c);
			pc.UpdateCompilationUnit(null, cu, cu.FileName);
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:54,代码来源:MyNamespaceBuilder.cs

示例2: ParseFile

		public static ParseInformation ParseFile(IProjectContent fileProjectContent, string fileName, string fileContent, bool updateCommentTags)
		{
			if (fileName == null) throw new ArgumentNullException("fileName");
			
			IParser parser = GetParser(fileName);
			if (parser == null) {
				return null;
			}
			
			ICompilationUnit parserOutput = null;
			
			try {
				if (fileProjectContent == null) {
					// GetProjectContent is expensive because it compares all file names, so
					// we accept the project content as optional parameter.
					fileProjectContent = GetProjectContent(fileName);
					if (fileProjectContent == null) {
						fileProjectContent = DefaultProjectContent;
					}
				}
				
				if (fileContent == null) {
					if (!File.Exists(fileName)) {
						return null;
					}
					fileContent = GetParseableFileContent(fileName);
				}
				parserOutput = parser.Parse(fileProjectContent, fileName, fileContent);
				
				if (parsings.ContainsKey(fileName)) {
					ParseInformation parseInformation = parsings[fileName];
					fileProjectContent.UpdateCompilationUnit(parseInformation.MostRecentCompilationUnit, parserOutput, fileName);
				} else {
					fileProjectContent.UpdateCompilationUnit(null, parserOutput, fileName);
				}
				if (updateCommentTags) {
					TaskService.UpdateCommentTags(fileName, parserOutput.TagComments);
				}
				return UpdateParseInformation(parserOutput, fileName, updateCommentTags);
			} catch (Exception e) {
				MessageService.ShowError(e);
			}
			return null;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:44,代码来源:ParserService.cs

示例3: ParseFile

		public static ParseInformation ParseFile(IProjectContent fileProjectContent, string fileName, string fileContent, bool updateCommentTags)
		{
			if (fileName == null) throw new ArgumentNullException("fileName");
			
			IParser parser = GetParser(fileName);
			if (parser == null) {
				return null;
			}
			
			ICompilationUnit parserOutput = null;
			
			try {
				if (fileProjectContent == null) {
					// GetProjectContent is expensive because it compares all file names, so
					// we accept the project content as optional parameter.
					fileProjectContent = GetProjectContent(fileName);
					if (fileProjectContent == null) {
						fileProjectContent = DefaultProjectContent;
					}
				}
				
				if (fileContent == null) {
					if (!File.Exists(fileName)) {
						return null;
					}
					fileContent = GetParseableFileContent(fileName);
				}
				parserOutput = parser.Parse(fileProjectContent, fileName, fileContent);
				parserOutput.Freeze();
				
				ParseInformation parseInformation;
				lock (parsings) {
					if (!parsings.TryGetValue(fileName, out parseInformation)) {
						parsings[fileName] = parseInformation = new ParseInformation();
					}
				}
				ICompilationUnit oldUnit = parseInformation.MostRecentCompilationUnit;
				fileProjectContent.UpdateCompilationUnit(oldUnit, parserOutput, fileName);
				parseInformation.SetCompilationUnit(parserOutput);
				if (updateCommentTags) {
					TaskService.UpdateCommentTags(fileName, parserOutput.TagComments);
				}
				try {
					OnParseInformationUpdated(new ParseInformationEventArgs(fileName, fileProjectContent, oldUnit, parserOutput));
				} catch (Exception e) {
					MessageService.ShowError(e);
				}
				return parseInformation;
			} catch (Exception e) {
				MessageService.ShowError(e, "Error parsing " + fileName);
			}
			return null;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:53,代码来源:ParserService.cs


注:本文中的IProjectContent.UpdateCompilationUnit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。