DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
DotNetDupe::System::IServiceProvider Class Referenceabstract

Defines a mechanism for retrieving a service object; that is, an object that provides custom support to other objects. More...

#include <IServiceProvider.h>

Inheritance diagram for DotNetDupe::System::IServiceProvider:

Public Member Functions

virtual ~IServiceProvider ()=default
 Virtual destructor for polymorphic interface cleanup.
template<typename T>
SmartPointer< T > GetRequiredService ()
 Gets service of type T, throwing InvalidOperationException if not found.
template<typename T>
SmartPointer< T > GetService ()
 Gets the service object of the specified generic type T.
virtual SmartPointer< ObjectGetService (const std::type_index &serviceType)=0
 Gets the service object of the specified type.
Public Member Functions inherited from DotNetDupe::System::Object
virtual ~Object ()=default
 Virtual destructor ensuring polymorphic cleanup.
virtual bool Equals (const Object &obj) const
 Determines whether the specified Object is equal to the current Object.
virtual int GetHashCode () const
 Serves as the default hash function.
bool operator== (const Object &obj) const
 Determines reference equality between two objects.
char * ToStringA () const
 Returns narrow-character string representation.
wchar_t * ToStringW () const
 Returns wide-character string representation.

Additional Inherited Members

Static Public Member Functions inherited from DotNetDupe::System::Object
static bool Equals (const Object &obj1, const Object &obj2)
 Static helper determining whether two object instances are equal.

Detailed Description

Defines a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.

Modeled after System.IServiceProvider in .NET Base Class Library (ECMA-335). Serves as the base resolution contract implemented by IoC containers across DotNetDupe. [ECMA-335]

Definition at line 20 of file IServiceProvider.h.

Constructor & Destructor Documentation

◆ ~IServiceProvider()

virtual DotNetDupe::System::IServiceProvider::~IServiceProvider ( )
virtualdefault

Virtual destructor for polymorphic interface cleanup.

Member Function Documentation

◆ GetRequiredService()

template<typename T>
SmartPointer< T > DotNetDupe::System::IServiceProvider::GetRequiredService ( )
inline

Gets service of type T, throwing InvalidOperationException if not found.

Template Parameters
TThe type of service object to get.
Returns
A service object of type T.
Exceptions
InvalidOperationExceptionThrown if the service cannot be resolved.

Definition at line 47 of file IServiceProvider.h.

References DotNetDupe::System::InvalidOperationException::InvalidOperationException(), GetService(), and DotNetDupe::System::SmartPointer< T >::IsNull().

◆ GetService() [1/2]

template<typename T>
SmartPointer< T > DotNetDupe::System::IServiceProvider::GetService ( )
inline

Gets the service object of the specified generic type T.

Template Parameters
TThe type of service object to get.
Returns
A service object of type T, or null if no such service is registered.

Definition at line 34 of file IServiceProvider.h.

References DotNetDupe::System::SmartPointer< T >::SmartPointer, DotNetDupe::System::DynamicCast(), GetService(), and DotNetDupe::System::SmartPointer< T >::IsNull().

◆ GetService() [2/2]

virtual SmartPointer< Object > DotNetDupe::System::IServiceProvider::GetService ( const std::type_index & serviceType)
pure virtual

Gets the service object of the specified type.

Parameters
serviceTypeAn object that specifies the type of service object to get.
Returns
A service object of type serviceType, or null if there is no service object of type serviceType.

Implemented in DotNetDupe::Extensions::DependencyInjection::ServiceProvider.

Referenced by GetRequiredService(), and GetService().


The documentation for this class was generated from the following file: