Ejemplo n.º 1
0
        /// <summary>
        /// Constructs an instance of <see cref="ComponentState"/>.
        /// </summary>
        /// <param name="renderer">The <see cref="Renderer"/> with which the new instance should be associated.</param>
        /// <param name="componentId">The externally visible identifier for the <see cref="IComponent"/>. The identifier must be unique in the context of the <see cref="Renderer"/>.</param>
        /// <param name="component">The <see cref="IComponent"/> whose state is being tracked.</param>
        /// <param name="parentComponentState">The <see cref="ComponentState"/> for the parent component, or null if this is a root component.</param>
        public ComponentState(Renderer renderer, int componentId, IComponent component, ComponentState parentComponentState)
        {
            ComponentId                = componentId;
            ParentComponentState       = parentComponentState;
            Component                  = component ?? throw new ArgumentNullException(nameof(component));
            _renderer                  = renderer ?? throw new ArgumentNullException(nameof(renderer));
            _cascadingParameters       = CascadingParameterState.FindCascadingParameters(this);
            CurrentRenderTree          = new RenderTreeBuilder();
            _renderTreeBuilderPrevious = new RenderTreeBuilder();

            if (_cascadingParameters.Count != 0)
            {
                _hasCascadingParameters = true;
                _hasAnyCascadingParameterSubscriptions = AddCascadingParameterSubscriptions();
            }
        }
Ejemplo n.º 2
0
 public static void InitializingComponent(ILogger logger, ComponentState componentState, ComponentState parentComponentState)
 {
     if (logger.IsEnabled(LogLevel.Debug)) // This is almost always false, so skip the evaluations
     {
         if (parentComponentState == null)
         {
             _initializingRootComponent(logger, componentState.ComponentId, componentState.Component.GetType(), null);
         }
         else
         {
             _initializingChildComponent(logger, componentState.ComponentId, componentState.Component.GetType(), parentComponentState.ComponentId, parentComponentState.Component.GetType(), null);
         }
     }
 }