共用方式為


ServiceCollectionDescriptorExtensions.TryAdd 方法

定義

多載

TryAdd(IServiceCollection, ServiceDescriptor)

如果尚未註冊服務類型,則將指定的 descriptor 新增至 collection

TryAdd(IServiceCollection, IEnumerable<ServiceDescriptor>)

如果尚未註冊服務類型,則將指定的 descriptors 新增至 collection

TryAdd(IServiceCollection, ServiceDescriptor)

來源:
ServiceCollectionDescriptorExtensions.cs
來源:
ServiceCollectionDescriptorExtensions.cs
來源:
ServiceCollectionDescriptorExtensions.cs

如果尚未註冊服務類型,則將指定的 descriptor 新增至 collection

public:
[System::Runtime::CompilerServices::Extension]
 static void TryAdd(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ descriptor);
public static void TryAdd (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Microsoft.Extensions.DependencyInjection.ServiceDescriptor descriptor);
static member TryAdd : Microsoft.Extensions.DependencyInjection.IServiceCollection * Microsoft.Extensions.DependencyInjection.ServiceDescriptor -> unit
<Extension()>
Public Sub TryAdd (collection As IServiceCollection, descriptor As ServiceDescriptor)

參數

descriptor
ServiceDescriptor

要加入的 ServiceDescriptor

適用於

TryAdd(IServiceCollection, IEnumerable<ServiceDescriptor>)

來源:
ServiceCollectionDescriptorExtensions.cs
來源:
ServiceCollectionDescriptorExtensions.cs
來源:
ServiceCollectionDescriptorExtensions.cs

如果尚未註冊服務類型,則將指定的 descriptors 新增至 collection

public:
[System::Runtime::CompilerServices::Extension]
 static void TryAdd(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, System::Collections::Generic::IEnumerable<Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^> ^ descriptors);
public static void TryAdd (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, System.Collections.Generic.IEnumerable<Microsoft.Extensions.DependencyInjection.ServiceDescriptor> descriptors);
static member TryAdd : Microsoft.Extensions.DependencyInjection.IServiceCollection * seq<Microsoft.Extensions.DependencyInjection.ServiceDescriptor> -> unit
<Extension()>
Public Sub TryAdd (collection As IServiceCollection, descriptors As IEnumerable(Of ServiceDescriptor))

參數

descriptors
IEnumerable<ServiceDescriptor>

要新增的 ServiceDescriptor

適用於