Answer the question
In order to leave comments, you need to log in
What are containers and component registration for?
Good day!
Began to study the full implementation of the WVVM pattern. During the study, I learned that they often use the "PRISM" library (I began to study it too). During the study of "PRISM" I learned that some containers are being implemented. And here are the first few questions: What is a container in this context and what is it for? Dependencies are also registered in this container. Here is a thread of questions: What is dependency registration and what is it for?
Here's the actual example:
public class Bootstrapper : AutofacBootstrapper
{
protected override DependencyObject CreateShell() => Container.Resolve<Shell>();
protected override void InitializeShell()
{
base.InitializeShell();
Application.Current.MainWindow = (Window)Shell;
Application.Current.MainWindow.Show();
}
protected override ContainerBuilder CreateContainerBuilder()
{
var builder = new ContainerBuilder();
// регистрация зависимостей в контейнере
// должны быть здесь...
return builder;
}
}
Answer the question
In order to leave comments, you need to log in
Dependency store container. The container is used to resolve dependencies, they say which specific implementation to substitute. Your dependency can be an interface - a class is an implementation of an interface, a class is a class successor, just a class. So, when registering, you match the type and its specific implementation.
for example
container.Register<IRegisterServer,DbRegisterService>();
container.Register<RegisterVieModel>();
.......
//Конструстор ViewModel
void RegisterViewModel(IRegisterService service)
{
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question