Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Method

TryAddKeyed

func TryAddKeyed(service: TypeInfo, key: object?, implementation: TypeInfo, lifetime: ServiceLifetime) -> Result<bool, ServiceError>

Declaring type: ServiceCollectionExtensions
Module: Neo.DependencyInjection
Assembly: Neo.DependencyInjection.Abstractions.dll

Extension from ServiceCollectionExtensions.TryAddKeyed

Adds an implementation only when its exact service type/key is absent.

Parameters

Name Type Description
self ServiceCollection
service TypeInfo
key Object?
implementation TypeInfo
lifetime ServiceLifetime

Return value

Result<Boolean, ServiceError>