test

@@@code

#r "nuget: HtmlAgilityPack.NetCore, 1.5.0.1"

#r "nuget: CsharpToColouredHTML.Core, 1.0.44"

#r "nuget: Microsoft.CodeAnalysis.CSharp, 4.9.2"

using CsharpToColouredHTML.Core;

using Microsoft.CodeAnalysis.CSharp;

using Microsoft.CodeAnalysis;

using HtmlAgilityPack;

using System.Linq;

 

string FormatContent(string csCode)

{

    var tree = CSharpSyntaxTree.ParseText(csCode);

    var root = tree.GetRoot().NormalizeWhitespace();var ret = root.ToFullString();

 

 

    return ret;

}

 

string sss = """

List<String> getGlobalRoleIdByRoleId(String id) {

SysRole role = queryEntity(id);

//默认角色才会涉及到上级非同类角色的管理,其它角色都是同角色内部管理

if (role.getName().equalsIgnoreCase(BUILD_IN_ROLE_CODE_BIZAdmin.getValue()) 

 

 

 

) {

//需要获取当前机构下的该类角色

 

 

 

 

//暂时直接请求全局的该类角色

 

 

 

 

SysRole bizAdminRole = getOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getCode, role.getName()).eq(SysRole::getCategory, SysRoleCategoryEnum.GLOBAL.getValue()));

return new ArrayList<String>() {{

    add(bizAdminRole.getId());

}};

}

return null;

}

""";

Console.WriteLine(FormatContent(sss));

var html = new CsharpColourer().ProcessSourceCode(FormatContent(sss), new HTMLEmitter(new HTMLEmitterSettings() { UseIframe = false }));

System.IO.File.WriteAllText(@"d:\temp\test.html", html);

//提取内容

sss = File.ReadAllText(@"D:\code\QinQouShui\QouShui\QBaiDuDoc\QBlog\bin\Debug\net8\word.txt");

var document = new HtmlDocument();

document.LoadHtml(sss);

Console.WriteLine(document.DocumentNode.InnerText);

@@#

posted @ 2024-04-19 18:26  秦秋随  阅读(2)  评论(0编辑  收藏  举报