private void TestRoundTrip(NativeSymbol symbol) { var storage = new BasicSymbolStorage(); var name = NativeNameUtil.GetName(symbol); var globalSymbol = new NativeGlobalSymbol(name, symbol); storage.Add(globalSymbol); TestRoundTrip(storage); }
internal override void Write(INativeSymbolLookup lookup) { foreach (var name in lookup.NativeNames) { if (name.Kind == NativeNameKind.EnumValue) { continue; } _storage.Add(lookup.GetGlobalSymbol(name)); } }
private BasicSymbolStorage Go() { var storage = new BasicSymbolStorage(); while (!_reader.IsDone()) { var symbol = Import(); storage.Add(symbol); } return(storage); }
internal static void Main(string[] args) { var dataDirectory = @"..\..\..\StorageGenerator\Data"; var oldFilePath = Path.Combine(dataDirectory, "windows.xml"); var newFilePath = Path.Combine(dataDirectory, "windows.csv"); Console.WriteLine("Reading old data"); var nativeStorage = new NativeStorage(); nativeStorage.ReadXml(oldFilePath); Console.WriteLine($"Converting to a {nameof(BasicSymbolStorage)}"); var storage = new BasicSymbolStorage(); foreach (var name in nativeStorage.NativeNames) { if (name.Kind == NativeNameKind.EnumValue) { continue; } NativeGlobalSymbol symbol; if (!nativeStorage.TryGetGlobalSymbol(name, out symbol)) { Console.WriteLine($"Error: Unable to load {name.Name} {name.Kind}"); continue; } storage.Add(symbol); } Console.WriteLine("Saving new data"); using (var stream = File.Open(newFilePath, FileMode.Create)) { StorageUtil.WriteCsv(stream, storage); } Console.WriteLine("Loading data for sanity check"); using (var stream = File.Open(newFilePath, FileMode.Open)) { var testStorage = StorageUtil.ReadCsv(stream); if (testStorage.Count != storage.Count) { Console.WriteLine("Error: Different count on load"); } } }