// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using Microsoft.AspNetCore.Blazor.RenderTree; namespace Microsoft.AspNetCore.Blazor.Test.Helpers { public class CapturedBatch { public IDictionary> DiffsByComponentId { get; } = new Dictionary>(); public IList DiffsInOrder { get; } = new List(); public IList DisposedComponentIDs { get; set; } public RenderTreeFrame[] ReferenceFrames { get; set; } internal void AddDiff(RenderTreeDiff diff) { var componentId = diff.ComponentId; if (!DiffsByComponentId.ContainsKey(componentId)) { DiffsByComponentId.Add(componentId, new List()); } // Clone the diff, because its underlying storage will get reused in subsequent batches var diffClone = new RenderTreeDiff( diff.ComponentId, new ArraySegment(diff.Edits.ToArray())); DiffsByComponentId[componentId].Add(diffClone); DiffsInOrder.Add(diffClone); } } }