Browse Source

remove unused code from ConnectionWizardWindow and properly implement exception handling

pull/18/head
Siegfried Pammer 14 years ago
parent
commit
c6e87d5b03
  1. 78
      src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/Windows/ConnectionWizardWindow.xaml.cs

78
src/AddIns/DisplayBindings/Data/ICSharpCode.Data.Core.UI/Windows/ConnectionWizardWindow.xaml.cs

@ -8,7 +8,7 @@ using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using ICSharpCode.Core;
using ICSharpCode.Data.Core.Interfaces; using ICSharpCode.Data.Core.Interfaces;
using System; using System;
using System.Threading; using System.Threading;
@ -31,7 +31,6 @@ namespace ICSharpCode.Data.Core.UI.Windows
private IDatasource _selectedDatasource = null; private IDatasource _selectedDatasource = null;
private IDatabase _selectedDatabase = null; private IDatabase _selectedDatabase = null;
private bool _isLoading = false; private bool _isLoading = false;
private Exception _datasourceException = null;
#endregion #endregion
@ -88,16 +87,6 @@ namespace ICSharpCode.Data.Core.UI.Windows
} }
} }
public Exception DatasourceException
{
get { return _datasourceException; }
set
{
_datasourceException = value;
OnPropertyChanged("DatasourceException");
}
}
#endregion #endregion
#region Constructor #region Constructor
@ -116,16 +105,6 @@ namespace ICSharpCode.Data.Core.UI.Windows
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { IsLoading = value; })); Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { IsLoading = value; }));
} }
private void SetException(Exception exception)
{
if (exception!= null) {
Dispatcher.BeginInvoke(DispatcherPriority.Background,
new Action(() => {MessageService.ShowError(exception.Message);}));
}
}
private void SetSelectedDatasource(IDatasource datasource) private void SetSelectedDatasource(IDatasource datasource)
{ {
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { SelectedDatasource = datasource; })); Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { SelectedDatasource = datasource; }));
@ -133,8 +112,6 @@ namespace ICSharpCode.Data.Core.UI.Windows
private void PopulateDatasources() private void PopulateDatasources()
{ {
SetException(null);
Thread thread = new Thread( Thread thread = new Thread(
new ThreadStart( new ThreadStart(
delegate() { delegate() {
@ -144,7 +121,10 @@ namespace ICSharpCode.Data.Core.UI.Windows
SelectedDatabaseDriver.PopulateDatasources(); SelectedDatabaseDriver.PopulateDatasources();
} }
} catch (Exception ex) { } catch (Exception ex) {
SetException(ex); Dispatcher.BeginInvoke(DispatcherPriority.Background,
new Action(() => {
MessageBox.Show(this, ex.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
}));
} finally { } finally {
SetIsLoading(false); SetIsLoading(false);
} }
@ -159,29 +139,27 @@ namespace ICSharpCode.Data.Core.UI.Windows
private void PopulateDatabases() private void PopulateDatabases()
{ {
SetException(null); Thread thread = new Thread(new ThreadStart(
delegate() {
Thread thread = new Thread(new ThreadStart(delegate() if (SelectedDatabaseDriver != null)
{ {
if (SelectedDatabaseDriver != null) SetIsLoading(true);
{
SetIsLoading(true); try
{
try SelectedDatabaseDriver.PopulateDatabases(_selectedDatasource);
{ }
SelectedDatabaseDriver.PopulateDatabases(_selectedDatasource); catch (Exception ex)
} {
catch (Exception ex) Dispatcher.BeginInvoke(DispatcherPriority.Background,
{ new Action(() => {
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => MessageBox.Show(this, ex.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
{ }));
MessageBox.Show(this, ex.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Error); }
}));
} SetIsLoading(false);
}
SetIsLoading(false); }));
}
}));
thread.SetApartmentState(ApartmentState.STA); thread.SetApartmentState(ApartmentState.STA);
thread.IsBackground = true; thread.IsBackground = true;
@ -241,13 +219,13 @@ namespace ICSharpCode.Data.Core.UI.Windows
#region INotifyPropertyChanged #region INotifyPropertyChanged
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string property) protected void OnPropertyChanged(string property)
{ {
if (PropertyChanged != null) if (PropertyChanged != null)
{ {
PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(property)); PropertyChanged(this, new PropertyChangedEventArgs(property));
} }
} }

Loading…
Cancel
Save