I am trying to implement my own custom IAbpSession
, but I do not know how to achieve the same property injection as IAbpSession
.
My AppServiceBase
is like below:
public abstract class EdwardAppServiceBase : ApplicationService
{
public TenantManager TenantManager { get; set; }
public UserManager UserManager { get; set; }
protected EdwardActiveUnitOfWork EdwardActiveUnitOfWork => (EdwardActiveUnitOfWork)UnitOfWorkManager.Current;
protected IEdwardSession EdwardSession { get; set; }
// protected IEdwardSession EdwardSession => AbpSession as IEdwardSession;
protected SensingStoreCloudAppServiceBase()
{
// EdwardSession = NullEdwardSession.Instance;
LocalizationSourceName = SensingStoreCloudConsts.LocalizationSourceName;
}
}
If I uncomment EdwardSession = NullEdwardSession.Instance;
, I always get NullEdwardSession
instead of IEdwardSession
implementation: EdwardSession
.
I could only do AbpSession as IEdwardSession
.
How does ABP inject IAbpSession
and set its value in ApplicationService
?
ABP uses Castle Windsor for dependency and property injection:
How properties are injected
Property injection of dependencies is designed to be done during component activation when a component is created. The responsibility of determining which properties are used for injection is fulfilled by default through
PropertiesDependenciesModelInspector
- aIContributeComponentModelConstruction
implementation which uses all the following criteria to determine if a property represents a dependency:
- Has 'public' accessible setter
- Is an instance property
- If
ComponentModel.InspectionBehavior
is set toPropertiesInspectionBehavior.DeclaredOnly
, is not inherited- Does not have parameters
- Is not annotated with the
Castle.Core.DoNotWireAttribute
attribute
So make it public
:
// protected IEdwardSession EdwardSession { get; set; }
public IEdwardSession EdwardSession { get; set; }