| File: ServiceLookup\ConstructorCallSite.cs | Web Access |
| Project: src\runtime\src\libraries\Microsoft.Extensions.DependencyInjection\src\Microsoft.Extensions.DependencyInjection.csproj (Microsoft.Extensions.DependencyInjection) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Reflection; namespace Microsoft.Extensions.DependencyInjection.ServiceLookup { internal sealed class ConstructorCallSite : ServiceCallSite { internal ConstructorInfo ConstructorInfo { get; } internal ServiceCallSite[] ParameterCallSites { get; } public ConstructorCallSite(ResultCache cache, Type serviceType, ConstructorInfo constructorInfo, object? serviceKey) : this(cache, serviceType, constructorInfo, Array.Empty<ServiceCallSite>(), serviceKey) { } public ConstructorCallSite(ResultCache cache, Type serviceType, ConstructorInfo constructorInfo, ServiceCallSite[] parameterCallSites, object? serviceKey) : base(cache, serviceKey) { if (!serviceType.IsAssignableFrom(constructorInfo.DeclaringType)) { throw new ArgumentException(SR.Format(SR.ImplementationTypeCantBeConvertedToServiceType, constructorInfo.DeclaringType, serviceType)); } ServiceType = serviceType; ConstructorInfo = constructorInfo; ParameterCallSites = parameterCallSites; } public override Type ServiceType { get; } public override Type? ImplementationType => ConstructorInfo.DeclaringType; public override CallSiteKind Kind { get; } = CallSiteKind.Constructor; } }