I'm developing a WPF app used by multiple persons on a network.
On startup I want to get the user name from Environment.UserName
and retrieve the user account from my database, then create a User
object.
Where should I do the user initialization? It seems logical to add a member User currentUser
to the Application
and do the initialization in the Main()
method, for example:
public class App : Application {
public User CurrentUser {
get; private set;
}
private Database database = new Database();
public static void Main() {
App app = new App();
CurrentUser = database.getUser(Environment.UserName);
app.InitializeComponent();
app.Run();
}
}
However I'm having doubts since the Main()
is auto generated in WPF.