26 : m_serviceType(typeid(void)),
27 m_implementationType(typeid(void)),
30 m_pInstance(nullptr) {}
37 const std::type_index& serviceType,
38 const std::type_index& implementationType,
40 ) : m_serviceType(serviceType),
41 m_implementationType(implementationType),
42 m_eLifetime(eLifetime),
44 m_pInstance(nullptr) {}
51 const std::type_index& serviceType,
54 ) : m_serviceType(serviceType),
55 m_implementationType(serviceType),
56 m_eLifetime(eLifetime),
57 m_fnFactory(std::move(fnFactory)),
58 m_pInstance(nullptr) {}
64 const std::type_index& serviceType,
66 ) : m_serviceType(serviceType),
67 m_implementationType(serviceType),
70 m_pInstance(std::move(pInstance)) {}
98 const std::type_index& serviceType,
99 const std::type_index& implementationType,
111 const std::type_index& serviceType,
124 template <
typename TService,
typename TImplementation,
typename... TArgs>
136 std::type_index m_serviceType;
137 std::type_index m_implementationType;
Defines a mechanism for retrieving a service object; that is, an object that provides custom support ...
Base object class for DotNetDupe mirroring .NET System.Object.
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
std::type_index GetServiceType() const
Gets the service type represented by this descriptor.
const FactoryType & GetFactory() const
Gets the optional factory function delegate.
const DotNetDupe::System::SmartPointer< DotNetDupe::System::Object > & GetInstance() const
Gets the optional pre-existing singleton instance.
ServiceDescriptor(const std::type_index &serviceType, FactoryType fnFactory, ServiceLifetime eLifetime)
Initializes a descriptor with a factory delegate.
static ServiceDescriptor Describe(const std::type_index &serviceType, FactoryType fnFactory, ServiceLifetime eLifetime)
Creates a ServiceDescriptor using a factory function delegate.
ServiceDescriptor(const std::type_index &serviceType, const std::type_index &implementationType, ServiceLifetime eLifetime)
Initializes a descriptor with explicit service type, implementation type, and lifetime.
std::function< DotNetDupe::System::SmartPointer< DotNetDupe::System::Object >(const DotNetDupe::System::SmartPointer< DotNetDupe::System::IServiceProvider > &)> FactoryType
Function signature for dynamic factory service instantiation delegates.
ServiceDescriptor(const std::type_index &serviceType, DotNetDupe::System::SmartPointer< DotNetDupe::System::Object > pInstance)
Initializes a descriptor with a pre-existing singleton instance.
ServiceDescriptor()
Default constructor initializing an empty descriptor.
static ServiceDescriptor Describe(ServiceLifetime eLifetime)
Creates a ServiceDescriptor resolving constructor dependencies via IServiceProvider.
static ServiceDescriptor Describe(const std::type_index &serviceType, const std::type_index &implementationType, ServiceLifetime eLifetime)
Creates a ServiceDescriptor with the specified service type, implementation type, and lifetime.
std::type_index GetImplementationType() const
Gets the concrete implementation type for this service.
ServiceLifetime GetLifetime() const
Gets the lifetime scope configured for this service.
Supports all classes in the DotNetDupe class hierarchy.
A unified smart pointer that supports both unique and shared ownership semantics.
static SmartPointer< T > NewShared()
Creates a Shared SmartPointer, default constructing T.
ServiceLifetime
Specifies the lifetime of a service in an IServiceCollection.
@ Singleton
Specifies that a single instance of the service will be created.
@ Transient
Specifies that a new instance of the service will be created every time it is requested.