diff --git a/src/HexManiac.Core/Models/Runs/Factory/TableStreamRunContentStrategy.cs b/src/HexManiac.Core/Models/Runs/Factory/TableStreamRunContentStrategy.cs index 04d25836..ae85d2f8 100644 --- a/src/HexManiac.Core/Models/Runs/Factory/TableStreamRunContentStrategy.cs +++ b/src/HexManiac.Core/Models/Runs/Factory/TableStreamRunContentStrategy.cs @@ -30,7 +30,10 @@ namespace HavenSoft.HexManiac.Core.Models.Runs.Factory { } return false; } - public override bool Matches(IFormattedRun run) => run is TableStreamRun streamRun && streamRun.FormatString == Format; + public override bool Matches(IFormattedRun run) { + if (run == null || run.FormatString != Format) return false; + return run is ITableRun; + } public override IFormattedRun WriteNewRun(IDataModel owner, ModelDelta token, int source, int destination, string name, IReadOnlyList sourceSegments) { // don't bother checking the TryParse result: we very much expect that the data originally in the run won't fit the parse. TableStreamRun.TryParseTableStream(owner, destination, new SortedSpan(source), name, Format, sourceSegments, out var tableStream); diff --git a/src/HexManiac.Core/ViewModels/Tools/StreamElementViewModel.cs b/src/HexManiac.Core/ViewModels/Tools/StreamElementViewModel.cs index 2ce94f1c..d1b979d7 100644 --- a/src/HexManiac.Core/ViewModels/Tools/StreamElementViewModel.cs +++ b/src/HexManiac.Core/ViewModels/Tools/StreamElementViewModel.cs @@ -148,8 +148,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Tools { if (destination == Pointer.NULL) { UsageCount = 0; } else { - var run = Model.GetNextRun(destination) as IStreamRun; - UsageCount = run?.PointerSources?.Count ?? 0; + var run = Model.GetNextRun(destination); + UsageCount = run is IStreamRun || run is ITableRun ? run.PointerSources?.Count ?? 0 : 0; } }