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)
{
ArgumentNullException.ThrowIfNull(serviceType, "serviceType");
ArgumentNullException.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)
{
ArgumentNullException.ThrowIfNull(serviceType, "serviceType");
ArgumentNullException.ThrowIfNull(instance, "instance");
_implementationInstance = instance;
}
public ServiceDescriptor(Type serviceType, Func<IServiceProvider, object> factory, ServiceLifetime lifetime)
: this(serviceType, (object)null, lifetime)
{
ArgumentNullException.ThrowIfNull(serviceType, "serviceType");
ArgumentNullException.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)
{
ArgumentNullException.ThrowIfNull(serviceType, "serviceType");
ArgumentNullException.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 defaultInterpolatedStringHandler2 = new DefaultInterpolatedStringHandler(3, 2);
defaultInterpolatedStringHandler2.AppendFormatted("ServiceKey");
defaultInterpolatedStringHandler2.AppendLiteral(": ");
defaultInterpolatedStringHandler2.AppendFormatted<object>(ServiceKey);
defaultInterpolatedStringHandler2.AppendLiteral(" ");
text = str + defaultInterpolatedStringHandler2.ToStringAndClear();
if (KeyedImplementationType != (Type)null) {
string str2 = text;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler3 = new DefaultInterpolatedStringHandler(2, 2);
defaultInterpolatedStringHandler3.AppendFormatted("KeyedImplementationType");
defaultInterpolatedStringHandler3.AppendLiteral(": ");
defaultInterpolatedStringHandler3.AppendFormatted(KeyedImplementationType);
return str2 + defaultInterpolatedStringHandler3.ToStringAndClear();
}
if (KeyedImplementationFactory != null) {
DiagnosticMethodInfo diagnosticMethodInfo = DiagnosticMethodInfo.Create(KeyedImplementationFactory);
string value = diagnosticMethodInfo?.DeclaringTypeName ?? "?";
string value2 = diagnosticMethodInfo?.Name ?? "?";
string str3 = text;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler4 = new DefaultInterpolatedStringHandler(3, 3);
defaultInterpolatedStringHandler4.AppendFormatted("KeyedImplementationFactory");
defaultInterpolatedStringHandler4.AppendLiteral(": ");
defaultInterpolatedStringHandler4.AppendFormatted(value);
defaultInterpolatedStringHandler4.AppendLiteral(".");
defaultInterpolatedStringHandler4.AppendFormatted(value2);
return str3 + defaultInterpolatedStringHandler4.ToStringAndClear();
}
string str4 = text;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler5 = new DefaultInterpolatedStringHandler(2, 2);
defaultInterpolatedStringHandler5.AppendFormatted("KeyedImplementationInstance");
defaultInterpolatedStringHandler5.AppendLiteral(": ");
defaultInterpolatedStringHandler5.AppendFormatted<object>(KeyedImplementationInstance);
return str4 + defaultInterpolatedStringHandler5.ToStringAndClear();
}
if (ImplementationType != (Type)null) {
string str5 = text;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler6 = new DefaultInterpolatedStringHandler(2, 2);
defaultInterpolatedStringHandler6.AppendFormatted("ImplementationType");
defaultInterpolatedStringHandler6.AppendLiteral(": ");
defaultInterpolatedStringHandler6.AppendFormatted(ImplementationType);
return str5 + defaultInterpolatedStringHandler6.ToStringAndClear();
}
if (ImplementationFactory != null) {
DiagnosticMethodInfo diagnosticMethodInfo2 = DiagnosticMethodInfo.Create(ImplementationFactory);
string value3 = diagnosticMethodInfo2?.DeclaringTypeName ?? "?";
string value4 = diagnosticMethodInfo2?.Name ?? "?";
string str6 = text;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler7 = new DefaultInterpolatedStringHandler(3, 3);
defaultInterpolatedStringHandler7.AppendFormatted("ImplementationFactory");
defaultInterpolatedStringHandler7.AppendLiteral(": ");
defaultInterpolatedStringHandler7.AppendFormatted(value3);
defaultInterpolatedStringHandler7.AppendLiteral(".");
defaultInterpolatedStringHandler7.AppendFormatted(value4);
return str6 + defaultInterpolatedStringHandler7.ToStringAndClear();
}
string str7 = text;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler8 = new DefaultInterpolatedStringHandler(2, 2);
defaultInterpolatedStringHandler8.AppendFormatted("ImplementationInstance");
defaultInterpolatedStringHandler8.AppendLiteral(": ");
defaultInterpolatedStringHandler8.AppendFormatted<object>(ImplementationInstance);
return str7 + defaultInterpolatedStringHandler8.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)
{
ArgumentNullException.ThrowIfNull(service, "service");
ArgumentNullException.ThrowIfNull(implementationType, "implementationType");
return Describe(service, implementationType, ServiceLifetime.Transient);
}
public static ServiceDescriptor KeyedTransient(Type service, [Nullable(2)] object serviceKey, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType)
{
ArgumentNullException.ThrowIfNull(service, "service");
ArgumentNullException.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
{
ArgumentNullException.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
{
ArgumentNullException.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Transient);
}
public static ServiceDescriptor Transient<TService>(Func<IServiceProvider, TService> implementationFactory) where TService : class
{
ArgumentNullException.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
{
ArgumentNullException.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Transient);
}
public static ServiceDescriptor Transient(Type service, Func<IServiceProvider, object> implementationFactory)
{
ArgumentNullException.ThrowIfNull(service, "service");
ArgumentNullException.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)
{
ArgumentNullException.ThrowIfNull(service, "service");
ArgumentNullException.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
{
ArgumentNullException.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
{
ArgumentNullException.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Scoped);
}
public static ServiceDescriptor Scoped<TService>(Func<IServiceProvider, TService> implementationFactory) where TService : class
{
ArgumentNullException.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
{
ArgumentNullException.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Scoped);
}
public static ServiceDescriptor Scoped(Type service, Func<IServiceProvider, object> implementationFactory)
{
ArgumentNullException.ThrowIfNull(service, "service");
ArgumentNullException.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)
{
ArgumentNullException.ThrowIfNull(service, "service");
ArgumentNullException.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)
{
ArgumentNullException.ThrowIfNull(service, "service");
ArgumentNullException.ThrowIfNull(implementationType, "implementationType");
return Describe(service, implementationType, ServiceLifetime.Singleton);
}
public static ServiceDescriptor KeyedSingleton(Type service, [Nullable(2)] object serviceKey, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type implementationType)
{
ArgumentNullException.ThrowIfNull(service, "service");
ArgumentNullException.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
{
ArgumentNullException.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
{
ArgumentNullException.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Singleton);
}
public static ServiceDescriptor Singleton<TService>(Func<IServiceProvider, TService> implementationFactory) where TService : class
{
ArgumentNullException.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
{
ArgumentNullException.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(typeof(TService), serviceKey, implementationFactory, ServiceLifetime.Singleton);
}
public static ServiceDescriptor Singleton(Type serviceType, Func<IServiceProvider, object> implementationFactory)
{
ArgumentNullException.ThrowIfNull(serviceType, "serviceType");
ArgumentNullException.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)
{
ArgumentNullException.ThrowIfNull(serviceType, "serviceType");
ArgumentNullException.ThrowIfNull(implementationFactory, "implementationFactory");
return DescribeKeyed(serviceType, serviceKey, implementationFactory, ServiceLifetime.Singleton);
}
public static ServiceDescriptor Singleton<TService>(TService implementationInstance) where TService : class
{
ArgumentNullException.ThrowIfNull(implementationInstance, "implementationInstance");
return Singleton(typeof(TService), implementationInstance);
}
public static ServiceDescriptor KeyedSingleton<TService>([Nullable(2)] object serviceKey, TService implementationInstance) where TService : class
{
ArgumentNullException.ThrowIfNull(implementationInstance, "implementationInstance");
return KeyedSingleton(typeof(TService), serviceKey, implementationInstance);
}
public static ServiceDescriptor Singleton(Type serviceType, object implementationInstance)
{
ArgumentNullException.ThrowIfNull(serviceType, "serviceType");
ArgumentNullException.ThrowIfNull(implementationInstance, "implementationInstance");
return new ServiceDescriptor(serviceType, implementationInstance);
}
public static ServiceDescriptor KeyedSingleton(Type serviceType, [Nullable(2)] object serviceKey, object implementationInstance)
{
ArgumentNullException.ThrowIfNull(serviceType, "serviceType");
ArgumentNullException.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 defaultInterpolatedStringHandler2 = new DefaultInterpolatedStringHandler(27, 1);
defaultInterpolatedStringHandler2.AppendLiteral(", ImplementationInstance = ");
defaultInterpolatedStringHandler2.AppendFormatted<object>(ImplementationInstance);
return str + defaultInterpolatedStringHandler2.ToStringAndClear();
}
string str2 = text;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler3 = new DefaultInterpolatedStringHandler(26, 1);
defaultInterpolatedStringHandler3.AppendLiteral(", ImplementationFactory = ");
defaultInterpolatedStringHandler3.AppendFormatted(ImplementationFactory.Method);
return str2 + defaultInterpolatedStringHandler3.ToStringAndClear();
}
return text + ", ImplementationType = \"" + ImplementationType.FullName + "\"";
}
string str3 = text;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler4 = new DefaultInterpolatedStringHandler(17, 1);
defaultInterpolatedStringHandler4.AppendLiteral(", ServiceKey = \"");
defaultInterpolatedStringHandler4.AppendFormatted<object>(ServiceKey);
defaultInterpolatedStringHandler4.AppendLiteral("\"");
text = str3 + defaultInterpolatedStringHandler4.ToStringAndClear();
if (!(KeyedImplementationType != (Type)null)) {
if (KeyedImplementationFactory == null) {
string str4 = text;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler5 = new DefaultInterpolatedStringHandler(32, 1);
defaultInterpolatedStringHandler5.AppendLiteral(", KeyedImplementationInstance = ");
defaultInterpolatedStringHandler5.AppendFormatted<object>(KeyedImplementationInstance);
return str4 + defaultInterpolatedStringHandler5.ToStringAndClear();
}
string str5 = text;
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler6 = new DefaultInterpolatedStringHandler(31, 1);
defaultInterpolatedStringHandler6.AppendLiteral(", KeyedImplementationFactory = ");
defaultInterpolatedStringHandler6.AppendFormatted(KeyedImplementationFactory.Method);
return str5 + defaultInterpolatedStringHandler6.ToStringAndClear();
}
return text + ", KeyedImplementationType = \"" + KeyedImplementationType.FullName + "\"";
}
private static void ThrowNonKeyedDescriptor()
{
throw new InvalidOperationException(System.SR.NonKeyedDescriptorMisuse);
}
}
}