public void LoadFlatFile(string rootNodePath, string filename, string formatfile = null, Encoding encoding = null) { if (formatfile == null) { var fi = new FileInfo(filename); formatfile = filename.Substring(0, filename.Length - fi.Extension.Length) + ".fmt"; } var mapNode = FormatReader.LoadFormatFile(formatfile, _nodes, rootNodePath, encoding ?? _defaultEncoding, _aliases); _mapSets[rootNodePath] = mapNode; using (var source = new FileStream(filename, FileMode.Open, FileAccess.Read)) { // Create node rows for parents of map node var nodes = new List <SharpNode> { mapNode.Parent }; while (nodes[0].Parent != null) { nodes.Insert(0, nodes[0].Parent); } nodes.Remove(nodes.Last()); var rows = nodes.Select(n => new SharpNodeRow(n)).ToList(); _rows.AddRange(rows); using (var reader = new FlatReader(source, mapNode, encoding ?? _defaultEncoding, SkipEmptyRows)) { _rows.InsertRows(reader.GetEnumerator(), rootRow: rows.Last()); } _rows.SubmitChanges(); } }
public void LoadFormatFile(string rootNodePath, string formatfile, Encoding encoding = null) { var mapNode = FormatReader.LoadFormatFile(formatfile, _nodes, rootNodePath, encoding ?? _defaultEncoding, _aliases); _mapSets[rootNodePath] = mapNode; }