문제

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