Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Personalization and dependency injection

Vote:
 

Hi!

I have a personalization criteria "DiscountIsActivatedCriterion" within this i have a parameterless constructer and the EPiServer IsMatch method. 

I need to apply a dependency injection inside the parameterless construtor. However EPiserver does not allow that. 

How do I go along about that?

#151434
Jul 21, 2016 13:46
Vote:
 

Hi 

You can use the ServiceLocator directly to get the instance you require: 

var myService = ServiceLocator.Current.GetInstance<IService>(); 

See this for more information:

http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Initialization/dependency-injection/

#151435
Jul 21, 2016 14:15
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.