/// <summary> /// Parse an incoming service descriptor instance & /// convert it into a useable Guppy TypeFactory/ServiceConfiguration /// </summary> /// <param name="descriptor"></param> /// <param name="services"></param> internal static void ConvertServiceDescriptor(this ServiceDescriptor descriptor, ServiceCollection services) { var implementationType = descriptor.ImplementationType ?? descriptor.ServiceType; var key = ServiceConfigurationKey.From(descriptor.ServiceType); var count = services.ServiceConfigurations.Count(c => c.Key == key); services.RegisterTypeFactory( type: implementationType, typeImplementation: implementationType, method: descriptor.CreateFactoryMethod(), priority: count); services.RegisterServiceConfiguration( key, descriptor.Lifetime, implementationType, ServiceConfigurationKey.From(implementationType).Yield(), priority: count); }