Working with Dependency Injection
In this code sample we will show an easy way to resolve services.
Required Modules
Samples
Python
from simplic import DependencyInjection
from Simplic.Authorization import IAuthorizationService
# Resolve instance. The resolve method has one argument, which accepts the type of the interface to resolve.
service = DependencyInjection.resolve(IAuthorizationService)
service.Migrate()
Internal method call
// The package uses the CommonServiceLocator to resolve the interface. The underlying clr-type is passed to the GetInstance method of the ServiceLocator:
public static object resolve(IronPython.Runtime.Types.PythonType type)
{
return CommonServiceLocator.ServiceLocator.Current.GetInstance(type.__clrtype__());
}