private async void buttonExport_Click(object sender, EventArgs e) { //Create Export Paramaters bool excludePrivates = radCheckBoxExcludePrivate.Checked; bool ignoreDynamicProperties = _settings.IgnoreDynamicallyAddedProperties; ExportType exportType = GetExportType(); int maxDepth = (int)numericUpDownMaxDepth.Value; ExportParamaters exportParamaters = new ExportParamaters(excludePrivates, ignoreDynamicProperties, maxDepth, exportType); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); _waitingDialog = new ProgressDialog(cancellationTokenSource); List <ExpressionWithSource> expressions = GetAllExpressions(); if (expressions.Any()) { //Hide and Show Progress Bar this.Hide(); _waitingDialog.Show(this); TypeRetriever retriever = new TypeRetriever(_dte2); var exportGenerator = new ExportGenerator(expressions, retriever, exportParamaters); try { Dictionary <string, string> lookupGeneratedTexts = await exportGenerator.GenerateTextWithKey(cancellationTokenSource.Token); //Setup event for when the form is shown to close the waiting dialog FormDisplayGeneratedText formDisplayGeneratedText = new FormDisplayGeneratedText(lookupGeneratedTexts, exportType); formDisplayGeneratedText.Shown += formDisplayGeneratedText_Shown; formDisplayGeneratedText.ShowDialog(this); } catch (ThreadAbortException ex) { _waitingDialog.Close(); } catch (ObjectDisposedException ex) { _waitingDialog.Close(); } catch (Exception ex) { _waitingDialog.Close(); Raygun.LogException(ex); MessageBox.Show("Error when attempting to export objects. If error reporting has not been disabled," + " then your error has already been logged."); } finally { this.Show(); } } }
public ExportGenerator(IEnumerable <ExpressionWithSource> expressionsWithSources, TypeRetriever retriever, ExportParamaters exportParamaters) { _type = exportParamaters.ExportType; _expressionsWithSources = expressionsWithSources; _maxDepth = exportParamaters.MaxDepth; List <IRuleSet> ruleSets = new List <IRuleSet>(); if (exportParamaters.ExcludePropertiesNotInClass) { ruleSets.Add(new PropertyInClassRuleSet(retriever)); } if (exportParamaters.ExludePrivateProperties) { ruleSets.Add(new AccesiblePropertiesRuleSet(retriever)); } _ruleSetValidator = new RuleSetValidator(ruleSets); }