partial void Initialize()
{
#if NET || SL5
var mainWindow = CatelEnvironment.MainWindow;
if (mainWindow != null)
{
mainWindow.Closing += (sender, e) =>
{
if (!_appClosedFromService)
{
_appClosingByMainWindow = true;
if (!CloseApplication())
{
Log.Debug("INavigationService.CloseApplication has canceled the closing of the main window");
e.Cancel = true;
}
_appClosingByMainWindow = false;
}
};
}
else
{
Log.Warning("Application.Current.MainWindow is null, cannot prevent application closing via service");
}
#endif
}