public static void Main(string[] args) { OpenFileDialog openDialog = new OpenFileDialog(); if (openDialog.ShowDialog() == DialogResult.OK) { string saveFile = openDialog.FileName; EsfFile file = EsfCodecUtil.LoadEsfFile(saveFile); ParentNode parent = file.RootNode as ParentNode; for (int i = 0; i < pathToCamera.Length; i++) { if (parent == null) { break; } parent = parent[pathToCamera[i]]; } if (parent == null || parent.Values.Count == 0) { MessageBox.Show("Could not find path to camera in save file :("); return; } EsfValueNode <uint> node = parent.Values[0] as EsfValueNode <uint>; node.FromString("1"); SaveFileDialog saveDialog = new SaveFileDialog { InitialDirectory = Path.GetDirectoryName(openDialog.FileName) }; if (saveDialog.ShowDialog() == DialogResult.OK) { EsfCodecUtil.WriteEsfFile(saveDialog.FileName, file); } } }
private EsfValueNode <T> TestNode <T>(EsfValueNode <T> node, EsfType expectedTypeCode = EsfType.INVALID) { byte[] data = encodeNode(node); EsfNode decoded = decodeNode(data); EsfValueNode <T> node2 = decoded as EsfValueNode <T>; assertEqual(node, node2); if (expectedTypeCode != EsfType.INVALID) { assertEqual(node2.TypeCode, expectedTypeCode); } encodeNode(node2); return(node2); }
public static void Main(string[] args) { AbcaFileCodec codec = new AbcaFileCodec { Header = new EsfHeader { ID = 0xABCA } }; RecordNode root = new RecordNode(codec) { Name = "root" }; RecordNode child = new RecordNode(codec) { Name = "copySource" }; EsfValueNode <string> utf16String = (EsfValueNode <string>)codec.CreateValueNode(EsfType.UTF16); utf16String.Value = "utf16"; child.Value.Add(utf16String); root.Value.Add(child); child = new RecordNode(codec) { Name = "copyTarget" }; EsfValueNode <string> copyString = (EsfValueNode <string>)utf16String.CreateCopy(); // copyString.Value = "copy"; copyString.FromString("copy"); child.Value.Add(copyString); root.Value.Add(child); // this is needed for the file to create the record nodes properly SortedList <int, string> nodeNames = new SortedList <int, string>(); nodeNames.Add(0, "root"); nodeNames.Add(1, "copySource"); nodeNames.Add(2, "copyTarget"); // this property needs to be added to the EsfFileCodec, getting and setting EsfFileCodec#nodeNames codec.NodeNames = nodeNames; EsfFile file = new EsfFile(root, codec); EsfCodecUtil.WriteEsfFile("string_container.esf", file); }