Exemple #1
0
        private static void OutputAsset(FrameAnalysis frameAnalysis, DirectoryInfo folder)
        {
            while (ui.GetInfo("a resource hash to dump lifecycle for", out var hex))
            {
                uint hash;
                try
                {
                    if (hex.Length != 8)
                    {
                        throw new InvalidDataException(nameof(hex));
                    }
                    hash = uint.Parse(hex, NumberStyles.HexNumber);
                }
                catch
                {
                    ui.Event($"Invalid hash: {hex} (must be 8 chars, alphanumetic hex)");
                    continue;
                }

                if (!frameAnalysis.Assets.TryGetValue(hash, out var asset))
                {
                    ui.Event($"Hash not found: {hex}");
                    continue;
                }

                using var assetFile = folder.File(asset.Hex + CSV.Extension).TryOpenWrite(ui);
                try
                {
                    if (assetFile != null)
                    {
                        AssetWriter.Write(asset, assetFile);
                        ui.Event($"Export of {asset.Hex} complete");
                        continue;
                    }
                }
                catch (Exception e)
                {
                    ui.Event(e.ToString());
                }
                ui.Event($"Export of {asset.Hex} failed:");
            }
            ui.Event("Export Asset aborted");
        }