Пример #1
0
        private void ImportFailed(Exception exception)
        {
            string message = exception != null ? exception.Message : Resources.Errors.TheOperationWasCancelled;

            CurrentUI = new Controls.ErrorUI(
                string.Format(CultureInfo.CurrentUICulture, Resources.Errors.ImportFailedWithMessage, message, "\n\n"),
                exception != null ? exception.StackTrace : "");
        }
Пример #2
0
        void select_SelectedIndexChanged(object sender, EventArgs e)
        {
            ImporterItem item = (select.SelectedItem as ImporterItem);

            if (item != null)
            {
                if (importer != null)
                {
                    UnwireImporterEvents();
                    importer.Dispose();
                }

                IImporterUI <IBilingualDictionary> newUI = null;

                if (item.Type.GetInterfaces().Contains(typeof(IDictionarySectionImporter)))
                {
                    var si  = (IDictionarySectionImporter)item.Type.GetConstructor(new Type[] { }).Invoke(new object[] { });
                    var dsi = new DualSectionImporter();
                    newUI    = new Controls.DictionarySectionUI(dsi, si);
                    importer = dsi;
                }
                else if (item.Type.IsSubclassOf(typeof(IBilingualDictionary)))
                {
                    importer = (IImporter <IBilingualDictionary>)item.Type.GetConstructor(new Type[] { }).Invoke(new object[] { });

                    foreach (Type t in importer.GetType().Assembly.GetTypes())
                    {
                        var attr = Attribute.GetCustomAttribute(t, typeof(ImporterUIAttribute)) as ImporterUIAttribute;
                        if (attr != null)
                        {
                            newUI = (IImporterUI <IBilingualDictionary>)Activator.CreateInstance(t, importer);
                            break;
                        }
                    }
                }

                WireImporterEvents();

                if (newUI == null)
                {
                    CurrentUI = new Controls.ErrorUI("No UI for " + item.Name, "");
                    UnwireImporterEvents();
                    importer.Dispose();
                    importer = null;
                    return;
                }

                newUI.Finished += new EventHandler(this.ImporterUIFinished);
                CurrentUI       = (Control)newUI;
            }
        }
Пример #3
0
		void select_SelectedIndexChanged(object sender, EventArgs e) {
			ImporterItem item = (select.SelectedItem as ImporterItem);
			if (item != null) {
				if (importer != null) {
					UnwireImporterEvents();
					importer.Dispose();
				}

				IImporterUI<IBilingualDictionary> newUI = null;

				if (item.Type.GetInterfaces().Contains(typeof(IDictionarySectionImporter))) {
					var si = (IDictionarySectionImporter)item.Type.GetConstructor(new Type[] { }).Invoke(new object[] { });
					var dsi = new DualSectionImporter();
					newUI = new Controls.DictionarySectionUI(dsi, si);
					importer = dsi;
				} else if(item.Type.IsSubclassOf(typeof(IBilingualDictionary))) {
					importer = (IImporter<IBilingualDictionary>)item.Type.GetConstructor(new Type[] { }).Invoke(new object[] { });

					foreach (Type t in importer.GetType().Assembly.GetTypes()) {
						var attr = Attribute.GetCustomAttribute(t, typeof(ImporterUIAttribute)) as ImporterUIAttribute;
						if (attr != null) {
							newUI = (IImporterUI<IBilingualDictionary>)Activator.CreateInstance(t, importer);
							break;
						}
					}
				}

				WireImporterEvents();
				
				if (newUI == null) {
					CurrentUI = new Controls.ErrorUI("No UI for " + item.Name, "");
					UnwireImporterEvents();
					importer.Dispose();
					importer = null;
					return;
				}

				newUI.Finished += this.ImporterUIFinished;
				CurrentUI = (Control)newUI;
			}
		}
Пример #4
0
		private void ImportFailed(Exception exception) {
			string message = exception != null ? exception.Message : Resources.Errors.TheOperationWasCancelled;
			CurrentUI = new Controls.ErrorUI(
				string.Format(CultureInfo.CurrentUICulture, Resources.Errors.ImportFailedWithMessage, message, "\n\n"),
				exception != null ? exception.StackTrace : "");
		}