CascadingValueServiceCollectionExtensions.TryAddCascadingValue Method

Definition

Overloads

TryAddCascadingValue<TValue>(IServiceCollection, Func<IServiceProvider,CascadingValueSource<TValue>>)

Adds a cascading value to the serviceCollection, if none is already registered with the value type. This is equivalent to having a fixed CascadingValue<TValue> at the root of the component hierarchy.

With this overload, you can supply a CascadingValueSource<TValue> which allows you to notify about updates to the value later, causing recipients to re-render. This overload should only be used if you plan to update the value dynamically.

TryAddCascadingValue<TValue>(IServiceCollection, Func<IServiceProvider,TValue>)

Adds a cascading value to the serviceCollection, if none is already registered with the value type. This is equivalent to having a fixed CascadingValue<TValue> at the root of the component hierarchy.

TryAddCascadingValue<TValue>(IServiceCollection, String, Func<IServiceProvider,TValue>)

Adds a cascading value to the serviceCollection, if none is already registered with the value type, regardless of the name. This is equivalent to having a fixed CascadingValue<TValue> at the root of the component hierarchy.

TryAddCascadingValue<TValue>(IServiceCollection, Func<IServiceProvider,CascadingValueSource<TValue>>)

Source:
CascadingValueServiceCollectionExtensions.cs

Adds a cascading value to the serviceCollection, if none is already registered with the value type. This is equivalent to having a fixed CascadingValue<TValue> at the root of the component hierarchy.

With this overload, you can supply a CascadingValueSource<TValue> which allows you to notify about updates to the value later, causing recipients to re-render. This overload should only be used if you plan to update the value dynamically.

public static void TryAddCascadingValue<TValue> (this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, Func<IServiceProvider,Microsoft.AspNetCore.Components.CascadingValueSource<TValue>> sourceFactory);
static member TryAddCascadingValue : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<IServiceProvider, Microsoft.AspNetCore.Components.CascadingValueSource<'Value>> -> unit
<Extension()>
Public Sub TryAddCascadingValue(Of TValue) (serviceCollection As IServiceCollection, sourceFactory As Func(Of IServiceProvider, CascadingValueSource(Of TValue)))

Type Parameters

TValue

The value type.

Parameters

serviceCollection
IServiceCollection

The IServiceCollection.

sourceFactory
Func<IServiceProvider,CascadingValueSource<TValue>>

A callback that supplies a CascadingValueSource<TValue> within each service provider scope.

Applies to

TryAddCascadingValue<TValue>(IServiceCollection, Func<IServiceProvider,TValue>)

Source:
CascadingValueServiceCollectionExtensions.cs

Adds a cascading value to the serviceCollection, if none is already registered with the value type. This is equivalent to having a fixed CascadingValue<TValue> at the root of the component hierarchy.

public static void TryAddCascadingValue<TValue> (this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, Func<IServiceProvider,TValue> valueFactory);
static member TryAddCascadingValue : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<IServiceProvider, 'Value> -> unit
<Extension()>
Public Sub TryAddCascadingValue(Of TValue) (serviceCollection As IServiceCollection, valueFactory As Func(Of IServiceProvider, TValue))

Type Parameters

TValue

The value type.

Parameters

serviceCollection
IServiceCollection

The IServiceCollection.

valueFactory
Func<IServiceProvider,TValue>

A callback that supplies a fixed value within each service provider scope.

Applies to

TryAddCascadingValue<TValue>(IServiceCollection, String, Func<IServiceProvider,TValue>)

Source:
CascadingValueServiceCollectionExtensions.cs

Adds a cascading value to the serviceCollection, if none is already registered with the value type, regardless of the name. This is equivalent to having a fixed CascadingValue<TValue> at the root of the component hierarchy.

public static void TryAddCascadingValue<TValue> (this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, string name, Func<IServiceProvider,TValue> valueFactory);
static member TryAddCascadingValue : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Func<IServiceProvider, 'Value> -> unit
<Extension()>
Public Sub TryAddCascadingValue(Of TValue) (serviceCollection As IServiceCollection, name As String, valueFactory As Func(Of IServiceProvider, TValue))

Type Parameters

TValue

The value type.

Parameters

serviceCollection
IServiceCollection

The IServiceCollection.

name
String

A name for the cascading value. If set, CascadingParameterAttribute can be configured to match based on this name.

valueFactory
Func<IServiceProvider,TValue>

A callback that supplies a fixed value within each service provider scope.

Applies to