Ejemplo n.º 1
0
        public void SetDirectParameters(ParameterView parameters)
        {
            // Note: We should be careful to ensure that the framework never calls
            // IComponent.SetParametersAsync directly elsewhere. We should only call it
            // via ComponentState.SetDirectParameters (or NotifyCascadingValueChanged below).
            // If we bypass this, the component won't receive the cascading parameters nor
            // will it update its snapshot of direct parameters.

            if (_hasAnyCascadingParameterSubscriptions)
            {
                // We may need to replay these direct parameters later (in NotifyCascadingValueChanged),
                // but we can't guarantee that the original underlying data won't have mutated in the
                // meantime, since it's just an index into the parent's RenderTreeFrames buffer.
                if (_latestDirectParametersSnapshot == null)
                {
                    _latestDirectParametersSnapshot = new ArrayBuilder <RenderTreeFrame>();
                }

                parameters.CaptureSnapshot(_latestDirectParametersSnapshot);
            }

            if (_cascadingParameters != null)
            {
                parameters = parameters.WithCascadingParameters(_cascadingParameters);
            }

            _renderer.AddToPendingTasks(Component.SetParametersAsync(parameters));
        }