Esempio n. 1
0
 private void addEncodingButton_Click(object sender, EventArgs e) {
   using (var dialog = new CreateNewSingleEncodingDialog()) {
     dialog.ForbiddenNames = Content.Encodings.Select(x => x.Name).Concat(new[] { Content.Name });
     if (dialog.ShowDialog() == DialogResult.OK) {
       IEncoding encoding;
       try {
         encoding = (IEncoding)Activator.CreateInstance(dialog.EncodingType, dialog.EncodingName);
       } catch (MissingMethodException mmex) {
         PluginInfrastructure.ErrorHandling.ShowErrorDialog("The encoding must have a constructor that takes the name as a single string argument", mmex);
         return;
       } catch (TargetInvocationException tiex) {
         PluginInfrastructure.ErrorHandling.ShowErrorDialog("The encoding could not be created due to an error in the constructor.", tiex);
         return;
       } catch (MethodAccessException maex) {
         PluginInfrastructure.ErrorHandling.ShowErrorDialog("The encoding's string constructor is not public.", maex);
         return;
       }
       Content.Add(encoding);
     }
   }
 }
 private void addEncodingButton_Click(object sender, EventArgs e)
 {
     using (var dialog = new CreateNewSingleEncodingDialog()) {
     dialog.ForbiddenNames = Content.Encodings.Select(x => x.Name).Concat(new[] { Content.Name });
     if (dialog.ShowDialog() == DialogResult.OK) {
       IEncoding encoding;
       try {
     encoding = (IEncoding)Activator.CreateInstance(dialog.EncodingType, dialog.EncodingName);
       } catch (MissingMethodException mmex) {
     PluginInfrastructure.ErrorHandling.ShowErrorDialog("The encoding must have a constructor that takes the name as a single string argument", mmex);
     return;
       } catch (TargetInvocationException tiex) {
     PluginInfrastructure.ErrorHandling.ShowErrorDialog("The encoding could not be created due to an error in the constructor.", tiex);
     return;
       } catch (MethodAccessException maex) {
     PluginInfrastructure.ErrorHandling.ShowErrorDialog("The encoding's string constructor is not public.", maex);
     return;
       }
       Content.Add(encoding);
     }
       }
 }