• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CSharpOutputVisitor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CSharpOutputVisitor的典型用法代码示例。如果您正苦于以下问题:C# CSharpOutputVisitor类的具体用法?C# CSharpOutputVisitor怎么用?C# CSharpOutputVisitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CSharpOutputVisitor类属于命名空间,在下文中一共展示了CSharpOutputVisitor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ToText

		public static string ToText(AbstractNode node)
		{
			var output = new CSharpOutputVisitor();
			node.AcceptVisitor(output, null);

			return output.Text;
		}
开发者ID:iamnilay3,项目名称:ravendb,代码行数:7,代码来源:QueryParsingUtils.cs


示例2: GenerateText

		public static string GenerateText(TypeDeclaration type, OrderedPartCollection<AbstractDynamicCompilationExtension> extensions)
		{
			var unit = new CompilationUnit();

			var namespaces = new HashSet<string>
			{
				typeof (SystemTime).Namespace,
				typeof (AbstractViewGenerator).Namespace,
				typeof (Enumerable).Namespace,
				typeof (IEnumerable<>).Namespace,
				typeof (IEnumerable).Namespace,
				typeof (int).Namespace,
				typeof (LinqOnDynamic).Namespace,
				typeof(Field).Namespace,
			};
			foreach (var extension in extensions)
			{
				foreach (var ns in extension.Value.GetNamespacesToImport())
				{
					namespaces.Add(ns);
				}
			}

			foreach (var ns in namespaces)
			{
				unit.AddChild(new Using(ns));
			}

			unit.AddChild(type);
			var output = new CSharpOutputVisitor();
			unit.AcceptVisitor(output, null);

			return output.Text;
		}
开发者ID:iamnilay3,项目名称:ravendb,代码行数:34,代码来源:QueryParsingUtils.cs


示例3: rewriteCode_CSharp

 public void rewriteCode_CSharp(CompilationUnit unit, IList<ISpecial> specials)
 {        	
     var outputVisitor  = new CSharpOutputVisitor();    		
     using (SpecialNodesInserter.Install(specials, outputVisitor)) {
         unit.AcceptVisitor(outputVisitor, null);
     }
     //codeTextBox.Text = outputVisitor.Text.Replace("\t", "  ");
     CSharpCode = outputVisitor.Text;
 }
开发者ID:pusp,项目名称:o2platform,代码行数:9,代码来源:AstDetails.cs


示例4: OutputNode

		public string OutputNode (ProjectDom dom, INode node, string indent)
		{
			CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor ();
			CSharpFormatter.SetFormatOptions (outputVisitor, dom != null && dom.Project != null ? dom.Project.Policies : null);
			int col = CSharpFormatter.GetColumn (indent, 0, 4);
			outputVisitor.OutputFormatter.IndentationLevel = System.Math.Max (0, col / 4);
			node.AcceptVisitor (outputVisitor, null);
			return outputVisitor.Text;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:9,代码来源:CSharpNRefactoryASTProvider.cs


示例5: GenerateParams

		protected string GenerateParams(Type eventType, bool paramNames)
		{
			CSharpOutputVisitor v = new CSharpOutputVisitor();
			MethodDeclaration md = ConvertEventInvokeMethodToNRefactory(CurrentClassPart, eventType, "name");
			if (md != null) {
				v.AppendCommaSeparatedList(md.Parameters);
			}
			return v.Text;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:9,代码来源:CSharpDesignerGenerator.cs


示例6: TestProgram

		void TestProgram(string program)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(program));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor();
			outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(StripWhitespace(program), StripWhitespace(outputVisitor.Text));
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:10,代码来源:CSharpOutputTest.cs


示例7: GenerateCode

		protected override string GenerateCode(INode unit, bool installSpecials)
		{
			CSharpOutputVisitor visitor = new CSharpOutputVisitor();
			
			if (installSpecials) {
				SpecialNodesInserter.Install(this.specialsList, visitor);
			}
			
			unit.AcceptVisitor(visitor, null);
			return visitor.Text;
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:11,代码来源:CSharpMethodExtractor.cs


示例8: TestProgram

		public void TestProgram(string input, string expectedOutput)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.VBNet, new StringReader(input));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			parser.CompilationUnit.AcceptVisitor(new VBNetToCSharpConvertVisitor(), null);
			CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor();
			outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(expectedOutput, outputVisitor.Text);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:11,代码来源:VBToCSharpConverterTest.cs


示例9: TestExpression

		void TestExpression(string expression)
		{
			// SEMICOLON HACK : without a trailing semicolon, parsing expressions does not work correctly
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(expression + ";"));
			Expression e = parser.ParseExpression();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			Assert.IsNotNull(e, "ParseExpression returned null");
			CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor();
			e.AcceptVisitor(outputVisitor, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(StripWhitespace(expression), StripWhitespace(outputVisitor.Text));
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:12,代码来源:CSharpOutputTest.cs


示例10: GenerateCode

        private static string GenerateCode(INode unit/*, bool installSpecials*/)
        {
            CSharpOutputVisitor visitor = new CSharpOutputVisitor();

            //			if (installSpecials)
            //			{
            //				SpecialNodesInserter.Install(this.specialsList, visitor);
            //			}

            unit.AcceptVisitor(visitor, null);
            return visitor.Text;
        }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:12,代码来源:INodeExt.cs


示例11: csharpCode

 public static string csharpCode(this INode iNode)
 {
     try
     {
         var outputVisitor = new CSharpOutputVisitor();
         iNode.AcceptVisitor(outputVisitor, null);
         return outputVisitor.Text;
     }
     catch (Exception ex)
     {
         ex.log("in CSharpSourceCode_ExtensionMethods.csharpCode");
         return "error creating source code for iNode. Error message was: ".format(ex.Message) ;
     }
 }
开发者ID:CallMeSteve,项目名称:FluentSharp,代码行数:14,代码来源:CSharpSourceCode_ExtensionMethods.cs


示例12: GenerateText

        public static string GenerateText(TypeDeclaration type)
        {
            var unit = new CompilationUnit();
            unit.AddChild(new Using(typeof (AbstractViewGenerator).Namespace));
            unit.AddChild(new Using(typeof (Enumerable).Namespace));
            unit.AddChild(new Using(typeof (int).Namespace));
            unit.AddChild(new Using(typeof (LinqOnDynamic).Namespace));
            unit.AddChild(type);

            var output = new CSharpOutputVisitor();
            unit.AcceptVisitor(output, null);

            return output.Text;
        }
开发者ID:kenegozi,项目名称:ravendb,代码行数:14,代码来源:QueryParsingUtils.cs


示例13: TestProgram

		public void TestProgram(string input, string expectedOutput)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.VBNet, new StringReader(input));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			parser.CompilationUnit.AcceptVisitor(new VBNetConstructsConvertVisitor(), null);
			parser.CompilationUnit.AcceptVisitor(new ToCSharpConvertVisitor(), null);
			CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor();
			outputVisitor.Options.IndentationChar = ' ';
			outputVisitor.Options.IndentSize = 2;
			outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(expectedOutput.Replace("\r", ""), outputVisitor.Text.Replace("\r", ""));
		}
开发者ID:sharpmonkey,项目名称:SharpDevelop,代码行数:14,代码来源:VBNetToCSharpConverterTest.cs


示例14: TestProgram

		void TestProgram(string program)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(program));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor();
			using (SpecialNodesInserter.Install(parser.Lexer.SpecialTracker.RetrieveSpecials(),
			                                    outputVisitor)) {
				outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			}
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(program.Replace("\r", ""), outputVisitor.Text.TrimEnd().Replace("\r", ""));
			parser.Dispose();
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:14,代码来源:SpecialOutputVisitor.cs


示例15: Main

		static int Main(string[] args)
		{
			File.Delete("conversion.log");
			
			try {
				List<string> map = new List<string>()
				{
					"..\\Controller\\Profiler",
					"..\\Controller\\Data\\UnmanagedCallTreeNode",
					"..\\Controller\\structs"
				};

				foreach (string path in map)
				{
					using (IParser parser = ParserFactory.CreateParser(path + ".cs"))
					{
						parser.Parse();

						if (parser.Errors.Count > 0)
						{
							string message = "Parser errors in file " + path + ":\n" + parser.Errors.ErrorOutput;
							Console.WriteLine(message);
							File.WriteAllText(path + "64.cs", message);
							return 2;
						}
						
						var specials = parser.Lexer.SpecialTracker.RetrieveSpecials().Where(item => item is PreprocessingDirective);
						
						parser.CompilationUnit.AcceptVisitor(new Converter(), null);
						CSharpOutputVisitor output = new CSharpOutputVisitor();
						SpecialNodesInserter.Install(specials, output);
						parser.CompilationUnit.AcceptVisitor(output, null);

						if (!File.Exists(path + "64.cs") || File.ReadAllText(path + "64.cs") != output.Text) {
							File.WriteAllText(path + "64.cs", output.Text);
						}
					}
				}

				return 0;
			} catch (Exception e) {
				File.WriteAllText("conversion.log", e.ToString());
				return -1;
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:45,代码来源:Program.cs


示例16: VB2CS

		void VB2CS(string input, string expectedOutput)
		{
			SnippetParser parser = new SnippetParser(SupportedLanguage.VBNet);
			INode node = parser.Parse(input);
			// parser.Errors.ErrorOutput contains syntax errors, if any
			Assert.IsNotNull(node);
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			// parser.Specials is the list of comments, preprocessor directives etc.
			PreprocessingDirective.VBToCSharp(parser.Specials);
			// Convert VB.NET constructs to C#:
			node.AcceptVisitor(new VBNetConstructsConvertVisitor(), null);
			node.AcceptVisitor(new ToCSharpConvertVisitor(), null);

			CSharpOutputVisitor output = new CSharpOutputVisitor();
			using (SpecialNodesInserter.Install(parser.Specials, output)) {
				node.AcceptVisitor(output, null);
			}
			// output.Errors.ErrorOutput contains conversion errors/warnings, if any
			// output.Text contains the converted code
			Assert.AreEqual("", output.Errors.ErrorOutput);
			Assert.AreEqual(expectedOutput, output.Text);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:22,代码来源:SnippetConversion.cs


示例17: Uninternalize

        public void Uninternalize(string file)
        {
            using (var parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(File.ReadAllText(file))))
            {
                parser.Parse();
                
                if (parser.Errors.Count > 0)
                {
                    Console.WriteLine(parser.Errors.ErrorOutput);
                    return;
                }

                var specials = parser.Lexer.SpecialTracker.RetrieveSpecials();

                parser.CompilationUnit.AcceptVisitor(new UninternalizerVisitor(), null);

                var visitor = new CSharpOutputVisitor();
                using (SpecialNodesInserter.Install(specials, visitor))
                    parser.CompilationUnit.AcceptVisitor(visitor, null);

                File.WriteAllText(file, visitor.Text);
            }
        }
开发者ID:bleissem,项目名称:SymbolSource.Community,代码行数:23,代码来源:Uninternalizer.cs


示例18: NestedInterfaceInGenericClass

		public void NestedInterfaceInGenericClass()
		{
			// See SD2-1626
			DefaultProjectContent pc = new DefaultProjectContent();
			pc.ReferencedContents.Add(SharedProjectContentRegistryForTests.Instance.Mscorlib);
			
			DefaultCompilationUnit cu = new DefaultCompilationUnit(pc);
			DefaultClass container = new DefaultClass(cu, "TestClass");
			container.TypeParameters.Add(new DefaultTypeParameter(container, "T", 0));
			
			DefaultClass innerClass = new DefaultClass(cu, container);
			innerClass.FullyQualifiedName = "TestClass.INestedInterface";
			innerClass.ClassType = ClassType.Interface;
			innerClass.TypeParameters.Add(new DefaultTypeParameter(innerClass, "T", 0));
			innerClass.Properties.Add(new DefaultProperty(innerClass, "P") {
			                          	ReturnType = new GenericReturnType(innerClass.TypeParameters[0]),
			                          	CanGet = true
			                          });
			container.InnerClasses.Add(innerClass);
			pc.AddClassToNamespaceList(container);
			
			DefaultClass targetClass = new DefaultClass(cu, "TargetClass");
			List<AbstractNode> nodes = new List<AbstractNode>();
			
			IReturnType interf = new SearchClassReturnType(pc, targetClass, 0, 0, "TestClass.INestedInterface", 1);
			interf = new ConstructedReturnType(interf, new IReturnType[] { SharedProjectContentRegistryForTests.Instance.Mscorlib.GetClass("System.String", 0).DefaultReturnType });
			
			CSharpCodeGenerator codeGen = new CSharpCodeGenerator();
			codeGen.ImplementInterface(nodes, interf, true, targetClass);
			
			Assert.AreEqual(1, nodes.Count);
			CSharpOutputVisitor output = new CSharpOutputVisitor();
			output.Options.IndentationChar = ' ';
			output.Options.IndentSize = 2;
			nodes[0].AcceptVisitor(output, null);
			Assert.AreEqual("string TestClass<string>.INestedInterface.P {\n  get {\n    throw new NotImplementedException();\n  }\n}", output.Text.Replace("\r", "").Trim());
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:37,代码来源:ImplementInterfaceTests.cs


示例19: CreateOutputVisitor

		public override IOutputAstVisitor CreateOutputVisitor()
		{
			CSharpOutputVisitor v = new CSharpOutputVisitor();
			PrettyPrintOptions pOpt = v.Options;
			
			BraceStyle braceStyle;
			if (this.Options.BracesOnSameLine) {
				braceStyle = BraceStyle.EndOfLine;
			} else {
				braceStyle = BraceStyle.NextLine;
			}
			pOpt.StatementBraceStyle = braceStyle;
			pOpt.EventAddBraceStyle = braceStyle;
			pOpt.EventRemoveBraceStyle = braceStyle;
			pOpt.PropertyBraceStyle = braceStyle;
			pOpt.PropertyGetBraceStyle = braceStyle;
			pOpt.PropertySetBraceStyle = braceStyle;
			
			pOpt.IndentationChar = this.Options.IndentString[0];
			pOpt.IndentSize = this.Options.IndentString.Length;
			pOpt.TabSize = this.Options.IndentString.Length;
			
			return v;
		}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:24,代码来源:CSharpCodeGenerator.cs


示例20: Print

 internal static void Print(AstNode node)
 {
     var v = new CSharpOutputVisitor (Console.Out, FormattingOptionsFactory.CreateMono ());
     node.AcceptVisitor (v);
 }
开发者ID:artifexor,项目名称:NRefactory,代码行数:5,代码来源:TestRefactoringContext.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CSharpParseOptions类代码示例发布时间:2022-05-24
下一篇:
C# CSharpFramework类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap