Creating a new instance of an object each time method is called

后端 未结 3 736
野趣味
野趣味 2021-01-06 05:41
Messenger.Default.Register(this, message =>
{
    var adventurerWindowVM = SimpleIoc.Default.GetInstance();
           


        
3条回答
  •  庸人自扰
    2021-01-06 06:17

    It's a method call, passing in an anonymous method using a lambda expression.

    It looks like you are getting your AdventurerViewModel from some sort of IoC container. How is the IoC container configured? In particular, what is the scope of the objects it gives you back? If you have the IoC configured to create objects in singleton scope, for example, then you will always get back a reference to the same object each time. You may need to configure the scope of the object in your IoC container so that it gives you back a fresh copy every time.

    How you do that will depend on your IoC container. Without knowing which IoC framework you are using or seeing its configuration, it's impossible to make any further comment.

提交回复
热议问题