ServiceDescriptor
Describes a service with its service type, implementation, and lifetime.
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace Microsoft.Extensions.DependencyInjection
{
[NullableContext(1)]
[Nullable(0)]
[DebuggerDisplay("{DebuggerToString(),nq}")]
public class ServiceDescriptor
{
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
private Type _implementationType;
private object _implementationInstance;
private object _implementationFactory;
public ServiceLifetime Lifetime { get; }
[Nullable(2)]
public object ServiceKey {
[NullableContext(2)]
get;
}
public Type ServiceType { get; }
[Nullable(2)]
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
public Type ImplementationType {
[NullableContext(2)]
get {
if (!IsKeyedService)
return _implementationType;
return null;
}
}
[Nullable(2)]
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
public Type KeyedImplementationType {
[NullableContext(2)]
get {
if (!IsKeyedService)
ThrowNonKeyedDescriptor();
return _implementationType;
}
}
[Nullable(2)]
public object ImplementationInstance {
[NullableContext(2)]
get {
if (!IsKeyedService)
return _implementationInstance;
return null;
}
}
[Nullable(2)]
public object KeyedImplementationInstance {
[NullableContext(2)]
get {
if (!IsKeyedService)
ThrowNonKeyedDescriptor();
return _implementationInstance;
}
}
[Nullable(new byte[] {
2,
1,
1
})]
public Func<IServiceProvider, object> ImplementationFactory {
[return: Nullable(new byte[] {
2,
1,
1
})]
get {
if (!IsKeyedService)
return (Func<IServiceProvider, object>)_implementationFactory;
return null;
}
}
[Nullable(new byte[] {
2,
1,
2,
1
})]
public Func<IServiceProvider, object, object> KeyedImplementationFactory {
[return: Nullable(new byte[] {
2,
1,
2,
1
})]
get {
if (!IsKeyedService)
ThrowNonKeyedDescriptor();
return (Func<IServiceProvider, object, object>)_implementationFactory;
}
}
public bool IsKeyedService => ServiceKey != null;
public ServiceDescriptor(Type serviceType, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType, ServiceLifetime lifetime)
: this(serviceType, null, implementationType, lifetime)
{
}
public ServiceDescriptor(Type serviceType, [Nullable(2)] object serviceKey, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType, ServiceLifetime lifetime)
: this(serviceType, serviceKey, lifetime)
{
System.ThrowHelper.ThrowIfNull(serviceType, "serviceType");
System.ThrowHelper.ThrowIfNull(implementationType, "implementationType");
_implementationType = implementationType;
}
public ServiceDescriptor(Type serviceType, object instance)
: this(serviceType, null, instance)
{
}
public ServiceDescriptor(Type serviceType, [Nullable(2)] object serviceKey, object instance)
: this(serviceType, serviceKey, ServiceLifetime.Singleton)
{
System.ThrowHelper.ThrowIfNull(serviceType, "serviceType");
System.ThrowHelper.ThrowIfNull(instance, "instance");
_implementationInstance = instance;
}
public ServiceDescriptor(Type serviceType, Func<IServiceProvider, object> factory, ServiceLifetime lifetime)
: this(serviceType, (object)null, lifetime)
{
System.ThrowHelper.ThrowIfNull(serviceType, "serviceType");
System.ThrowHelper.ThrowIfNull(factory, "factory");
_implementationFactory = factory;
}
public ServiceDescriptor(Type serviceType, [Nullable(2)] object serviceKey, [Nullable(new byte[] {
1,
1,
2,
1
})] Func<IServiceProvider, object, object> factory, ServiceLifetime lifetime)
: this(serviceType, serviceKey, lifetime)
{
System.ThrowHelper.ThrowIfNull(serviceType, "serviceType");
System.ThrowHelper.ThrowIfNull(factory, "factory");
if (serviceKey == null) {
Func<IServiceProvider, object> func = (Func<IServiceProvider, object>)(_implementationFactory = (Func<IServiceProvider, object>)((IServiceProvider sp) => factory(sp, null)));
} else
_implementationFactory = factory;
}
private ServiceDescriptor(Type serviceType, object serviceKey, ServiceLifetime lifetime)
{
Lifetime = lifetime;
ServiceType = serviceType;
ServiceKey = serviceKey;
}
public override string ToString()
{
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(6, 4);
defaultInterpolatedStringHandler.AppendFormatted("ServiceType");
defaultInterpolatedStringHandler.AppendLiteral(": ");
defaultInterpolatedStringHandler.AppendFormatted(ServiceType);
defaultInterpolatedStringHandler.AppendLiteral(" ");
defaultInterpolatedStringHandler.AppendFormatted("Lifetime");
defaultInterpolatedStringHandler.AppendLiteral(": ");
defaultInterpolatedStringHandler.AppendFormatted(Lifetime);
defaultInterpolatedStringHandler.AppendLiteral(" ");
string text = defaultInterpolatedStringHandler.ToStringAndClear();
if (IsKeyedService) {
string str = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(3, 2);
defaultInterpolatedStringHandler.AppendFormatted("ServiceKey");
defaultInterpolatedStringHandler.AppendLiteral(": ");
defaultInterpolatedStringHandler.AppendFormatted<object>(ServiceKey);
defaultInterpolatedStringHandler.AppendLiteral(" ");
text = str + defaultInterpolatedStringHandler.ToStringAndClear();
if (KeyedImplementationType != (Type)null) {
string str2 = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(2, 2);
defaultInterpolatedStringHandler.AppendFormatted("KeyedImplementationType");
defaultInterpolatedStringHandler.AppendLiteral(": ");
defaultInterpolatedStringHandler.AppendFormatted(KeyedImplementationType);
return str2 + defaultInterpolatedStringHandler.ToStringAndClear();
}
if (KeyedImplementationFactory != null) {
string str3 = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(2, 2);
defaultInterpolatedStringHandler.AppendFormatted("KeyedImplementationFactory");
defaultInterpolatedStringHandler.AppendLiteral(": ");
defaultInterpolatedStringHandler.AppendFormatted(KeyedImplementationFactory.Method);
return str3 + defaultInterpolatedStringHandler.ToStringAndClear();
}
string str4 = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(2, 2);
defaultInterpolatedStringHandler.AppendFormatted("KeyedImplementationInstance");
defaultInterpolatedStringHandler.AppendLiteral(": ");
defaultInterpolatedStringHandler.AppendFormatted<object>(KeyedImplementationInstance);
return str4 + defaultInterpolatedStringHandler.ToStringAndClear();
}
if (ImplementationType != (Type)null) {
string str5 = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(2, 2);
defaultInterpolatedStringHandler.AppendFormatted("ImplementationType");
defaultInterpolatedStringHandler.AppendLiteral(": ");
defaultInterpolatedStringHandler.AppendFormatted(ImplementationType);
return str5 + defaultInterpolatedStringHandler.ToStringAndClear();
}
if (ImplementationFactory != null) {
string str6 = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(2, 2);
defaultInterpolatedStringHandler.AppendFormatted("ImplementationFactory");
defaultInterpolatedStringHandler.AppendLiteral(": ");
defaultInterpolatedStringHandler.AppendFormatted(ImplementationFactory.Method);
return str6 + defaultInterpolatedStringHandler.ToStringAndClear();
}
string str7 = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(2, 2);
defaultInterpolatedStringHandler.AppendFormatted("ImplementationInstance");
defaultInterpolatedStringHandler.AppendLiteral(": ");
defaultInterpolatedStringHandler.AppendFormatted<object>(ImplementationInstance);
return str7 + defaultInterpolatedStringHandler.ToStringAndClear();
}
internal Type GetImplementationType()
{
if (ServiceKey == null) {
if (ImplementationType != (Type)null)
return ImplementationType;
if (ImplementationInstance != null)
return ImplementationInstance.GetType();
if (ImplementationFactory != null)
return ImplementationFactory.GetType().GenericTypeArguments[1];
} else {
if (KeyedImplementationType != (Type)null)
return KeyedImplementationType;
if (KeyedImplementationInstance != null)
return KeyedImplementationInstance.GetType();
if (KeyedImplementationFactory != null)
return KeyedImplementationFactory.GetType().GenericTypeArguments[2];
}
return null;
}
public static ServiceDescriptor Transient<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>() where TService : class where TImplementation : class, TService
{
return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Transient);
}
public static ServiceDescriptor KeyedTransient<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>([Nullable(2)] object serviceKey) where TService : class where TImplementation : class, TService
{
return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Transient);
}
public static ServiceDescriptor Transient(Type service, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType)
{
System.ThrowHelper.ThrowIfNull(service, "service");
System.ThrowHelper.ThrowIfNull(implementationType, "implementationType");
return Describe(service, implementationType, ServiceLifetime.Transient);
}
public static ServiceDescriptor KeyedTransient(Type service, [Nullable(2)] object serviceKey, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType)
{
System.ThrowHelper.ThrowIfNull(service, "service");
System.ThrowHelper.ThrowIfNull(implementationType, "implementationType");
return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Transient);
}
public static ServiceDescriptor Transient<TService, TImplementation>(Func<IServiceProvider, TImplementation> implementationFactory) where TService : class where TImplementation : class, TService
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return Describe(typeof(TService), implementationFactory, ServiceLifetime.Transient);
}
public static ServiceDescriptor KeyedTransient<TService, TImplementation>([Nullable(2)] object serviceKey, [Nullable(new byte[] {
1,
1,
2,
1
})] Func<IServiceProvider, object, TImplementation> implementationFactory) where TService : class where TImplementation : class, TService
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Transient);
}
public static ServiceDescriptor Transient<TService>(Func<IServiceProvider, TService> implementationFactory) where TService : class
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return Describe(typeof(TService), implementationFactory, ServiceLifetime.Transient);
}
public static ServiceDescriptor KeyedTransient<TService>([Nullable(2)] object serviceKey, [Nullable(new byte[] {
1,
1,
2,
1
})] Func<IServiceProvider, object, TService> implementationFactory) where TService : class
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Transient);
}
public static ServiceDescriptor Transient(Type service, Func<IServiceProvider, object> implementationFactory)
{
System.ThrowHelper.ThrowIfNull(service, "service");
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return Describe(service, implementationFactory, ServiceLifetime.Transient);
}
public static ServiceDescriptor KeyedTransient(Type service, [Nullable(2)] object serviceKey, [Nullable(new byte[] {
1,
1,
2,
1
})] Func<IServiceProvider, object, object> implementationFactory)
{
System.ThrowHelper.ThrowIfNull(service, "service");
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(service, serviceKey, implementationFactory, ServiceLifetime.Transient);
}
public static ServiceDescriptor Scoped<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>() where TService : class where TImplementation : class, TService
{
return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Scoped);
}
public static ServiceDescriptor KeyedScoped<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>([Nullable(2)] object serviceKey) where TService : class where TImplementation : class, TService
{
return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Scoped);
}
public static ServiceDescriptor Scoped(Type service, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType)
{
return Describe(service, implementationType, ServiceLifetime.Scoped);
}
public static ServiceDescriptor KeyedScoped(Type service, [Nullable(2)] object serviceKey, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType)
{
return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Scoped);
}
public static ServiceDescriptor Scoped<TService, TImplementation>(Func<IServiceProvider, TImplementation> implementationFactory) where TService : class where TImplementation : class, TService
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return Describe(typeof(TService), implementationFactory, ServiceLifetime.Scoped);
}
public static ServiceDescriptor KeyedScoped<TService, TImplementation>([Nullable(2)] object serviceKey, [Nullable(new byte[] {
1,
1,
2,
1
})] Func<IServiceProvider, object, TImplementation> implementationFactory) where TService : class where TImplementation : class, TService
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Scoped);
}
public static ServiceDescriptor Scoped<TService>(Func<IServiceProvider, TService> implementationFactory) where TService : class
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return Describe(typeof(TService), implementationFactory, ServiceLifetime.Scoped);
}
public static ServiceDescriptor KeyedScoped<TService>([Nullable(2)] object serviceKey, [Nullable(new byte[] {
1,
1,
2,
1
})] Func<IServiceProvider, object, TService> implementationFactory) where TService : class
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Scoped);
}
public static ServiceDescriptor Scoped(Type service, Func<IServiceProvider, object> implementationFactory)
{
System.ThrowHelper.ThrowIfNull(service, "service");
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return Describe(service, implementationFactory, ServiceLifetime.Scoped);
}
public static ServiceDescriptor KeyedScoped(Type service, [Nullable(2)] object serviceKey, [Nullable(new byte[] {
1,
1,
2,
1
})] Func<IServiceProvider, object, object> implementationFactory)
{
System.ThrowHelper.ThrowIfNull(service, "service");
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(service, serviceKey, implementationFactory, ServiceLifetime.Scoped);
}
public static ServiceDescriptor Singleton<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>() where TService : class where TImplementation : class, TService
{
return DescribeKeyed<TService, TImplementation>(null, ServiceLifetime.Singleton);
}
public static ServiceDescriptor KeyedSingleton<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>([Nullable(2)] object serviceKey) where TService : class where TImplementation : class, TService
{
return DescribeKeyed<TService, TImplementation>(serviceKey, ServiceLifetime.Singleton);
}
public static ServiceDescriptor Singleton(Type service, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType)
{
System.ThrowHelper.ThrowIfNull(service, "service");
System.ThrowHelper.ThrowIfNull(implementationType, "implementationType");
return Describe(service, implementationType, ServiceLifetime.Singleton);
}
public static ServiceDescriptor KeyedSingleton(Type service, [Nullable(2)] object serviceKey, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType)
{
System.ThrowHelper.ThrowIfNull(service, "service");
System.ThrowHelper.ThrowIfNull(implementationType, "implementationType");
return DescribeKeyed(service, serviceKey, implementationType, ServiceLifetime.Singleton);
}
public static ServiceDescriptor Singleton<TService, TImplementation>(Func<IServiceProvider, TImplementation> implementationFactory) where TService : class where TImplementation : class, TService
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return Describe(typeof(TService), implementationFactory, ServiceLifetime.Singleton);
}
public static ServiceDescriptor KeyedSingleton<TService, TImplementation>([Nullable(2)] object serviceKey, [Nullable(new byte[] {
1,
1,
2,
1
})] Func<IServiceProvider, object, TImplementation> implementationFactory) where TService : class where TImplementation : class, TService
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Singleton);
}
public static ServiceDescriptor Singleton<TService>(Func<IServiceProvider, TService> implementationFactory) where TService : class
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return Describe(typeof(TService), implementationFactory, ServiceLifetime.Singleton);
}
public static ServiceDescriptor KeyedSingleton<TService>([Nullable(2)] object serviceKey, [Nullable(new byte[] {
1,
1,
2,
1
})] Func<IServiceProvider, object, TService> implementationFactory) where TService : class
{
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Singleton);
}
public static ServiceDescriptor Singleton(Type serviceType, Func<IServiceProvider, object> implementationFactory)
{
System.ThrowHelper.ThrowIfNull(serviceType, "serviceType");
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return Describe(serviceType, implementationFactory, ServiceLifetime.Singleton);
}
public static ServiceDescriptor KeyedSingleton(Type serviceType, [Nullable(2)] object serviceKey, [Nullable(new byte[] {
1,
1,
2,
1
})] Func<IServiceProvider, object, object> implementationFactory)
{
System.ThrowHelper.ThrowIfNull(serviceType, "serviceType");
System.ThrowHelper.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(serviceType, serviceKey, implementationFactory, ServiceLifetime.Singleton);
}
public static ServiceDescriptor Singleton<TService>(TService implementationInstance) where TService : class
{
System.ThrowHelper.ThrowIfNull(implementationInstance, "implementationInstance");
return Singleton(typeof(TService), implementationInstance);
}
public static ServiceDescriptor KeyedSingleton<TService>([Nullable(2)] object serviceKey, TService implementationInstance) where TService : class
{
System.ThrowHelper.ThrowIfNull(implementationInstance, "implementationInstance");
return KeyedSingleton(typeof(TService), serviceKey, implementationInstance);
}
public static ServiceDescriptor Singleton(Type serviceType, object implementationInstance)
{
System.ThrowHelper.ThrowIfNull(serviceType, "serviceType");
System.ThrowHelper.ThrowIfNull(implementationInstance, "implementationInstance");
return new ServiceDescriptor(serviceType, implementationInstance);
}
public static ServiceDescriptor KeyedSingleton(Type serviceType, [Nullable(2)] object serviceKey, object implementationInstance)
{
System.ThrowHelper.ThrowIfNull(serviceType, "serviceType");
System.ThrowHelper.ThrowIfNull(implementationInstance, "implementationInstance");
return new ServiceDescriptor(serviceType, serviceKey, implementationInstance);
}
private static ServiceDescriptor DescribeKeyed<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>(object serviceKey, ServiceLifetime lifetime) where TService : class where TImplementation : class, TService
{
return DescribeKeyed(typeof(TService), serviceKey, typeof(TImplementation), lifetime);
}
public static ServiceDescriptor Describe(Type serviceType, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType, ServiceLifetime lifetime)
{
return new ServiceDescriptor(serviceType, implementationType, lifetime);
}
public static ServiceDescriptor DescribeKeyed(Type serviceType, [Nullable(2)] object serviceKey, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType, ServiceLifetime lifetime)
{
return new ServiceDescriptor(serviceType, serviceKey, implementationType, lifetime);
}
public static ServiceDescriptor Describe(Type serviceType, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime)
{
return new ServiceDescriptor(serviceType, implementationFactory, lifetime);
}
public static ServiceDescriptor DescribeKeyed(Type serviceType, [Nullable(2)] object serviceKey, [Nullable(new byte[] {
1,
1,
2,
1
})] Func<IServiceProvider, object, object> implementationFactory, ServiceLifetime lifetime)
{
return new ServiceDescriptor(serviceType, serviceKey, implementationFactory, lifetime);
}
private string DebuggerToString()
{
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(29, 2);
defaultInterpolatedStringHandler.AppendLiteral("Lifetime = ");
defaultInterpolatedStringHandler.AppendFormatted(Lifetime);
defaultInterpolatedStringHandler.AppendLiteral(", ServiceType = \"");
defaultInterpolatedStringHandler.AppendFormatted(ServiceType.FullName);
defaultInterpolatedStringHandler.AppendLiteral("\"");
string text = defaultInterpolatedStringHandler.ToStringAndClear();
if (!IsKeyedService) {
if (!(ImplementationType != (Type)null)) {
if (ImplementationFactory == null) {
string str = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(27, 1);
defaultInterpolatedStringHandler.AppendLiteral(", ImplementationInstance = ");
defaultInterpolatedStringHandler.AppendFormatted<object>(ImplementationInstance);
return str + defaultInterpolatedStringHandler.ToStringAndClear();
}
string str2 = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(26, 1);
defaultInterpolatedStringHandler.AppendLiteral(", ImplementationFactory = ");
defaultInterpolatedStringHandler.AppendFormatted(ImplementationFactory.Method);
return str2 + defaultInterpolatedStringHandler.ToStringAndClear();
}
return text + ", ImplementationType = \"" + ImplementationType.FullName + "\"";
}
string str3 = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(17, 1);
defaultInterpolatedStringHandler.AppendLiteral(", ServiceKey = \"");
defaultInterpolatedStringHandler.AppendFormatted<object>(ServiceKey);
defaultInterpolatedStringHandler.AppendLiteral("\"");
text = str3 + defaultInterpolatedStringHandler.ToStringAndClear();
if (!(KeyedImplementationType != (Type)null)) {
if (KeyedImplementationFactory == null) {
string str4 = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(32, 1);
defaultInterpolatedStringHandler.AppendLiteral(", KeyedImplementationInstance = ");
defaultInterpolatedStringHandler.AppendFormatted<object>(KeyedImplementationInstance);
return str4 + defaultInterpolatedStringHandler.ToStringAndClear();
}
string str5 = text;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(31, 1);
defaultInterpolatedStringHandler.AppendLiteral(", KeyedImplementationFactory = ");
defaultInterpolatedStringHandler.AppendFormatted(KeyedImplementationFactory.Method);
return str5 + defaultInterpolatedStringHandler.ToStringAndClear();
}
return text + ", KeyedImplementationType = \"" + KeyedImplementationType.FullName + "\"";
}
private static void ThrowNonKeyedDescriptor()
{
throw new InvalidOperationException(System.SR.NonKeyedDescriptorMisuse);
}
}
}