Exemplo n.º 1
0
        public bool TryDisposeInBatch(RenderBatchBuilder batchBuilder, out Exception exception)
        {
            _componentWasDisposed = true;
            exception             = null;

            try
            {
                if (Component is IDisposable disposable)
                {
                    disposable.Dispose();
                }
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            // We don't expect these things to throw.
            RenderTreeDiffBuilder.DisposeFrames(batchBuilder, CurrentRenderTree.GetFrames());

            if (_hasAnyCascadingParameterSubscriptions)
            {
                RemoveCascadingParameterSubscriptions();
            }

            DisposeBuffers();

            return(exception == null);
        }
Exemplo n.º 2
0
        public void RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
        {
            // A component might be in the render queue already before getting disposed by an
            // earlier entry in the render queue. In that case, rendering is a no-op.
            if (_componentWasDisposed)
            {
                return;
            }

            // Swap the old and new tree builders
            (CurrentRenderTree, _renderTreeBuilderPrevious) = (_renderTreeBuilderPrevious, CurrentRenderTree);

            CurrentRenderTree.Clear();
            renderFragment(CurrentRenderTree);

            var diff = RenderTreeDiffBuilder.ComputeDiff(
                _renderer,
                batchBuilder,
                ComponentId,
                _renderTreeBuilderPrevious.GetFrames(),
                CurrentRenderTree.GetFrames());

            batchBuilder.UpdatedComponentDiffs.Append(diff);
            batchBuilder.InvalidateParameterViews();
        }
Exemplo n.º 3
0
 public ParameterViewLifetime(RenderBatchBuilder owner)
 {
     _owner = owner;
     _stamp = owner.ParameterViewValidityStamp;
 }