public static string GenerateCSharp(BaseSyntax ast, int tabSize = 4, string @namespace = null) { var options = new ApexSharpParserOptions { TabSize = tabSize }; if (!string.IsNullOrWhiteSpace(@namespace)) { options.Namespace = @namespace; } return(GenerateCSharp(ast, options)); }
public static string GenerateCSharp(BaseSyntax ast, ApexSharpParserOptions options) { // set default options options = options ?? new ApexSharpParserOptions(); var generator = new CSharpCodeGenerator { IndentSize = options.TabSize, Namespace = options.Namespace, UseLocalSObjectsNamespace = options.UseLocalSObjectsNamespace, }; ast.Accept(generator); return(generator.Code.ToString()); }
// Convert Apex Code to C# with custom options public static string ConvertToCSharp(string apexCode, ApexSharpParserOptions options) { return(ApexSharpParser.GetApexAst(apexCode).ToCSharp(options)); }
public static string ToCSharp(this BaseSyntax node, ApexSharpParserOptions options) => CSharpCodeGenerator.GenerateCSharp(node, options);