Methods for injecting dependencies into a domain model

I have a domain model type. One of its many properties requires ITranslationService to be able to translate the return value into the appropriate language.

Do I have to embed ITranslationService in the constructor of the type of the domain model (so that it changes everywhere when the type is created and must be associated with initialization when retrieving through NhIbernate), although it is used by the tiny part of the type (one of many properties); or is there another functional pattern that I can use?

Does anyone have any relevant experience that they can share?

+3
source share
2 answers

, - ( ) . ,

var translatedString = yourServiceInstance.Translate(theDomainObject.Property);
+4

Source: https://habr.com/ru/post/1756915/


All Articles