本文整理汇总了C#中CSharpOutputVisitor类的典型用法代码示例。如果您正苦于以下问题:C# CSharpOutputVisitor类的具体用法?C# CSharpOutputVisitor怎么用?C# CSharpOutputVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CSharpOutputVisitor类属于命名空间,在下文中一共展示了CSharpOutputVisitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToText
public static string ToText(AbstractNode node)
{
var output = new CSharpOutputVisitor();
node.AcceptVisitor(output, null);
return output.Text;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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) ;
}
}
示例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;
}
示例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", ""));
}
示例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();
}
示例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;
}
}