1 Star 0 Fork 0

哈里/JSON改

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
模仿类.vb 1.88 KB
一键复制 编辑 原始数据 按行查看 历史
哈里 提交于 2024-10-29 10:24 +08:00 . fix: 一些优化
Imports System.IO
Imports System.Threading
Public Class 模仿类
Public 模仿集 As New Dictionary(Of String, List(Of HarryNode))
Public 加载完成 As Boolean
Private 加载路径 As String
Public Sub New(path As String)
加载路径 = path
Dim t As New Thread(AddressOf Load)
t.Start()
End Sub
Private Sub Load()
If Not Directory.Exists(加载路径) Then
Return
End If
Dim directories = Directory.GetDirectories(加载路径)
For Each d In directories
Dim files = Directory.GetFiles(d)
Dim setName As String = IO.Path.GetFileName(d)
模仿集.Add(setName, New List(Of HarryNode))
For Each f In files
If IO.Path.GetExtension(f) = ".json" Then
模仿集(setName).Add(New HarryNode("root", File.ReadAllText(f)))
End If
Next
Next
End Sub
Public Function GetSets() As List(Of String)
Return 模仿集.Keys.ToList
End Function
Public Function GetPath(setName As String, rootPath As String) As Dictionary(Of String, HarryNode)
Dim result As New Dictionary(Of String, HarryNode)
If Not 模仿集.ContainsKey(setName) Then
Return result
End If
For Each node As HarryNode In 模仿集(setName)
If node.GetAtt(rootPath) IsNot Nothing Then
Dim childNode As HarryNode = node.GetNode(rootPath)
For Each childPath In childNode.GetChildPath
If result.ContainsKey(childPath) Then
result(childPath).Merge(childNode.GetNode(childPath))
Else
result.Add(childPath, childNode.GetNode(childPath))
End If
Next
End If
Next
Return result
End Function
End Class
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Visual Basic
1
https://gitee.com/harryxiaocn/json-modification.git
git@gitee.com:harryxiaocn/json-modification.git
harryxiaocn
json-modification
JSON改
master

搜索帮助