// 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. namespace Microsoft.AspNetCore.Blazor.RenderTree { /// /// Represents a single edit operation on a component's render tree. /// public readonly struct RenderTreeEdit { /// /// Gets the type of the edit operation. /// public readonly RenderTreeEditType Type; /// /// Gets the index of the sibling frame that the edit relates to. /// public readonly int SiblingIndex; /// /// Gets the index of related data in an associated render frames array. For example, if the /// value is , gets the /// index of the new frame data in an associated render tree. /// public readonly int ReferenceFrameIndex; /// /// If the value is , /// gets the name of the attribute that is being removed. /// public readonly string RemovedAttributeName; private RenderTreeEdit(RenderTreeEditType type) : this() { Type = type; } private RenderTreeEdit(RenderTreeEditType type, int siblingIndex) : this() { Type = type; SiblingIndex = siblingIndex; } private RenderTreeEdit(RenderTreeEditType type, int siblingIndex, int referenceFrameIndex) : this() { Type = type; SiblingIndex = siblingIndex; ReferenceFrameIndex = referenceFrameIndex; } private RenderTreeEdit(RenderTreeEditType type, int siblingIndex, string removedAttributeName) : this() { Type = type; SiblingIndex = siblingIndex; RemovedAttributeName = removedAttributeName; } internal static RenderTreeEdit RemoveFrame(int siblingIndex) => new RenderTreeEdit(RenderTreeEditType.RemoveFrame, siblingIndex); internal static RenderTreeEdit PrependFrame(int siblingIndex, int referenceFrameIndex) => new RenderTreeEdit(RenderTreeEditType.PrependFrame, siblingIndex, referenceFrameIndex); internal static RenderTreeEdit UpdateText(int siblingIndex, int referenceFrameIndex) => new RenderTreeEdit(RenderTreeEditType.UpdateText, siblingIndex, referenceFrameIndex); internal static RenderTreeEdit SetAttribute(int siblingIndex, int referenceFrameIndex) => new RenderTreeEdit(RenderTreeEditType.SetAttribute, siblingIndex, referenceFrameIndex); internal static RenderTreeEdit RemoveAttribute(int siblingIndex, string name) => new RenderTreeEdit(RenderTreeEditType.RemoveAttribute, siblingIndex, name); internal static RenderTreeEdit StepIn(int siblingIndex) => new RenderTreeEdit(RenderTreeEditType.StepIn, siblingIndex); internal static RenderTreeEdit StepOut() => new RenderTreeEdit(RenderTreeEditType.StepOut); } }