public FileV8Tree GetLeaf(params int[] values) { FileV8Tree current = this; foreach (var value in values) { current = current._leaves[value]; } return(current); }
public FileV8Tree AddLeaf(string key, string value, FileV8Tree parent = null) { if (_leaves == null) { _leaves = new List <FileV8Tree>(); } FileV8Tree newLeaf = new FileV8Tree(key, value, parent); _leaves.Add(newLeaf); return(newLeaf); }
/// <summary> /// Parses 1CV8 data from <see cref="System.IO.MemoryStream"/> /// </summary> /// <param name="stream"> /// <see cref="System.IO.MemoryStream"/>, passed by reference, /// that contains the deflated data to parse /// </param> /// <param name="fileName"> /// Value, that will be put into tree root /// <see cref="_1CV8Adapters.FileV8Tree.Value"/> /// </param> /// <returns> /// Returns <see cref="_1CV8Adapters.FileV8Tree"/> with parsed data in /// leaves /// </returns> /// <example> This sample shows how to use /// the ParseV8File method from your plugin /// <code> /// /// using (FileV8Reader v8Reader = new FileV8Reader(Input)) /// { /// var fileSystem = v8Reader.ReadV8FileSystem(); /// foreach (var reference in fileSystem.References) /// { /// using (MemoryStream stream = new MemoryStream()) /// { /// v8Reader.ReadV8FileRawData(stream, file); /// FileV8Tree result = v8Reader.ParseV8File(stream, reference.FileHeader.FileName); /// /// // some yours сode /// /// } /// } /// } /// /// </code> /// </example> /// <permission cref="System.Security.PermissionSet">Everyone /// can access this method. /// </permission> public FileV8Tree ParseV8File(MemoryStream stream, string fileName) { FileV8Tree tree = new FileV8Tree(@"Entry", fileName); FileV8Tree parent = tree; int level = -1; bool isData = false; bool isText = false; using (StreamReader reader = new StreamReader(stream)) { if (reader.Peek() != '{') { parent.AddLeaf(@"unknown", reader.ReadToEnd(), parent); } else { StringBuilder sb = new StringBuilder(); while (!reader.EndOfStream) { char[] array = reader.ReadLine().ToCharArray(); foreach (var c in array) { if (c.Equals('"')) { isText = !isText; sb.Append(c); continue; } if (isText) { sb.Append(c); continue; } if (c.Equals(',')) { if (isData) { parent.AddLeaf(@"unknown", sb.ToString(), parent); sb.Clear(); } else { isData = true; } continue; } if (c.Equals('{')) { level++; isData = true; if (level > 0) { parent = parent.AddLeaf(@"unknown", @"unknown", parent); } continue; } if (c.Equals('}')) { if (isData) { isData = false; parent.AddLeaf(@"unknown", sb.ToString(), parent); sb.Clear(); } level--; parent = parent.Parent; continue; } if (isData) { sb.Append(c); } } // Adding CR+LF if (isText) { sb.Append("\r\n"); } } } } return(tree); }
private FileV8Tree GetModelsTree(FileV8Tree rootPropertiesTree) { if (rootPropertiesTree.GetLeaf(3, 1, 3, 0).Value.Equals(@"3daea016-69b7-4ed4-9453-127911372fe6")) { return rootPropertiesTree.GetLeaf(3, 1, 3); } else if (rootPropertiesTree.GetLeaf(3, 1, 4, 0).Value.Equals(@"3daea016-69b7-4ed4-9453-127911372fe6")) { return rootPropertiesTree.GetLeaf(3, 1, 4); } return null; }
private FileV8Tree GetFormsTree(FileV8Tree rootPropertiesTree) { if (rootPropertiesTree.GetLeaf(3, 1, 5, 0).Value.Equals(@"d5b0e5ed-256d-401c-9c36-f630cafd8a62")) { return rootPropertiesTree.GetLeaf(3, 1, 5); } else if (rootPropertiesTree.GetLeaf(3, 1, 5, 0).Value.Equals(@"a3b368c0-29e2-11d6-a3c7-0050bae0a776")) { return rootPropertiesTree.GetLeaf(3, 1, 5); } return null; }
public FileV8Tree(string key, string value, FileV8Tree parent = null) { _key = key; _value = value; _parent = parent; }
public FileV8Tree AddLeaf(string key, string value, FileV8Tree parent = null) { if(_leaves == null) { _leaves = new List<FileV8Tree>(); } FileV8Tree newLeaf = new FileV8Tree(key, value, parent); _leaves.Add(newLeaf); return newLeaf; }
/// <summary> /// Parses 1CV8 data from <see cref="System.IO.MemoryStream"/> /// </summary> /// <param name="stream"> /// <see cref="System.IO.MemoryStream"/>, passed by reference, /// that contains the deflated data to parse /// </param> /// <param name="fileName"> /// Value, that will be put into tree root /// <see cref="_1CV8Adapters.FileV8Tree.Value"/> /// </param> /// <returns> /// Returns <see cref="_1CV8Adapters.FileV8Tree"/> with parsed data in /// leaves /// </returns> /// <example> This sample shows how to use /// the ParseV8File method from your plugin /// <code> /// /// using (FileV8Reader v8Reader = new FileV8Reader(Input)) /// { /// var fileSystem = v8Reader.ReadV8FileSystem(); /// foreach (var reference in fileSystem.References) /// { /// using (MemoryStream stream = new MemoryStream()) /// { /// v8Reader.ReadV8FileRawData(stream, file); /// FileV8Tree result = v8Reader.ParseV8File(stream, reference.FileHeader.FileName); /// /// // some yours сode /// /// } /// } /// } /// /// </code> /// </example> /// <permission cref="System.Security.PermissionSet">Everyone /// can access this method. /// </permission> public FileV8Tree ParseV8File(MemoryStream stream, string fileName) { FileV8Tree tree = new FileV8Tree(@"Entry", fileName); FileV8Tree parent = tree; int level = -1; bool isData = false; bool isText = false; using (StreamReader reader = new StreamReader(stream)) { if (reader.Peek() != '{') { parent.AddLeaf(@"unknown", reader.ReadToEnd(), parent); } else { StringBuilder sb = new StringBuilder(); while (!reader.EndOfStream) { char[] array = reader.ReadLine().ToCharArray(); foreach (var c in array) { if (c.Equals('"')) { isText = !isText; sb.Append(c); continue; } if (isText) { sb.Append(c); continue; } if (c.Equals(',')) { if (isData) { parent.AddLeaf(@"unknown", sb.ToString(), parent); sb.Clear(); } else { isData = true; } continue; } if (c.Equals('{')) { level++; isData = true; if (level > 0) { parent = parent.AddLeaf(@"unknown", @"unknown", parent); } continue; } if (c.Equals('}')) { if (isData) { isData = false; parent.AddLeaf(@"unknown", sb.ToString(), parent); sb.Clear(); } level--; parent = parent.Parent; continue; } if (isData) { sb.Append(c); } } // Adding CR+LF if (isText) { sb.Append("\r\n"); } } } } return tree; }