提交 4c419bf2 编写于 作者: T tanghai

修复转成json的错误

上级 acc65280
......@@ -36,7 +36,7 @@
<add key="Port" value="8888"/>
<add key="Account" value="egametang@163.com"/>
<add key="Password" value="163bio1"/>
<add key="NodePath" value="D:\Source\Demo\battledemo\Assets\Resources\Config\node.bytes"/>
<add key="NodePath" value="D:\Source\SLOL\Program\Unity\Assets\Resources\Config\NodeProto.txt"/>
<add key="ClientSettingsProvider.ServiceUri" value=""/>
</appSettings>
<system.serviceModel>
......
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using System.IO;
......@@ -33,8 +34,17 @@ namespace Modules.BehaviorTreeModule
var treeDict = new Dictionary<int, List<TreeNodeData>>();
AllTreeData allTreeData = new AllTreeData();
string content = File.ReadAllText(file);
AllTreeData allTreeData = MongoHelper.FromJson<AllTreeData>(content);
foreach (string line in content.Split(new[] { "\r\n" }, StringSplitOptions.None))
{
if (line.Trim() == "")
{
continue;
}
TreeNodeData treeNodeData = MongoHelper.FromJson<TreeNodeData>(line);
allTreeData.TreeNodeDatas.Add(treeNodeData);
}
this.MaxNodeId = 0;
this.MaxTreeId = 0;
......@@ -71,14 +81,18 @@ namespace Modules.BehaviorTreeModule
AllTreeData allTreeData = new AllTreeData();
foreach (TreeViewModel value in this.treeViewModelsDict.Values)
{
List<TreeNodeData> list = value.GetDatas();//
List<TreeNodeData> list = value.GetDatas();
allTreeData.TreeNodeDatas.AddRange(list);
}
using (StreamWriter stream = new StreamWriter(new FileStream(file, FileMode.Create, FileAccess.Write)))
{
string content = MongoHelper.ToJson(allTreeData);
stream.Write(content);
foreach (TreeNodeData treeNodeData in allTreeData.TreeNodeDatas)
{
string content = MongoHelper.ToJson(treeNodeData);
stream.Write(content);
stream.Write("\r\n");
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册