Вопрос

in my application i had done log-in in WPF using prism after log-in i have to store some value (like user_id,username etc) that can be accessible in to may module so how can i resolve that problem using prism with MEF

   private void Login()
        {
            try
            {
                authentication.Login(LoginModel.UserName, LoginModel.Password);             
                // what i want to do here
                (new InventoryBootstrapper()).Run();                   
                App.Current.Windows[0].Close();
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;   
            }            
        }
Это было полезно?

Решение

There are two ways that I know of.

First you can have a 'Common' service. Use this as a service like any other module you register, it gets instantiated when the app opens, then you can call this service and use the values within as you need to.

Secondly, you could also have a 'Common' project that every module references, from your core module to all modules.

Другие советы

Alternatively, use the container to store / retrieve the value:

store:

this.container.RegisterInstance<string>("NameOfValue", "abc123");

retrieve:

string nameOfValue = this.container.Resolve<string>("NameOfValue");

The code will have to handle the case where nameOfValue cannot be resolved and, as such, is null.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top