Ejemplo n.º 1
0
        public static string[] CollectArgs(IWin32Window parent, string report, string[] oldArgs)
        {
            const string conditionColumnName = "Condition"; // Not L10N

            // Split report (.csv file) by lines
            string[] lines      = report.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
            string[] fields     = lines[0].ParseCsvFields();
            int      groupIndex = Array.IndexOf(fields, conditionColumnName);

            if (groupIndex < 0)
            {
                MessageBox.Show(parent,
                                string.Format(MSstatsResources.MSstatsGroupComparisonCollector_CollectArgs_Unable_to_find_a_column_named___0__,
                                              conditionColumnName));
                return(null);
            }

            ICollection <string> groups = new HashSet <string>();

            // The last line in the CSV file is empty, thus we compare length - 1
            for (int i = 1; i < lines.Length - 1; i++)
            {
                try
                {
                    groups.Add(lines[i].ParseCsvFields()[groupIndex]);
                }
                catch
                {
                    // ignore
                }
            }

            using (var dlg = new GroupComparisonUi(groups.ToArray(), oldArgs))
            {
                var result = parent != null?dlg.ShowDialog(parent) : dlg.ShowDialog();

                if (result != DialogResult.OK)
                {
                    return(null);
                }
                return(dlg.Arguments);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This entry point might be used future versions of Skyline in case the report text is too
        /// large to fit in a string.
        /// </summary>
        public static string[] CollectArgsReader(IWin32Window parent, TextReader report, string[] oldArgs)
        {
            const string conditionColumnName = "Condition"; // Not L10N
            var          parser = new TextFieldParser(report);

            parser.SetDelimiters(",");
            string[] fields     = parser.ReadFields() ?? new string[0];
            int      groupIndex = Array.IndexOf(fields, conditionColumnName);

            if (groupIndex < 0)
            {
                MessageBox.Show(parent,
                                string.Format(MSstatsResources.MSstatsGroupComparisonCollector_CollectArgs_Unable_to_find_a_column_named___0__,
                                              conditionColumnName));
                return(null);
            }

            ICollection <string> groups = new HashSet <string>();

            // The last line in the CSV file is empty, thus we compare length - 1
            string[] line;
            while ((line = parser.ReadFields()) != null)
            {
                groups.Add(line[groupIndex]);
            }
            using (var dlg = new GroupComparisonUi(groups.ToArray(), oldArgs))
            {
                var result = parent != null?dlg.ShowDialog(parent) : dlg.ShowDialog();

                if (result != DialogResult.OK)
                {
                    return(null);
                }
                return(dlg.Arguments);
            }
        }
Ejemplo n.º 3
0
        public static string[] CollectArgs(IWin32Window parent, string report, string[] oldArgs)
        {
            const string conditionColumnName = "Condition"; // Not L10N
            // Split report (.csv file) by lines
            string[] lines = report.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
            string[] fields = lines[0].ParseCsvFields();
            int groupIndex = Array.IndexOf(fields, conditionColumnName);
            if (groupIndex < 0)
            {
                MessageBox.Show(parent,
                    string.Format(MSstatsResources.MSstatsGroupComparisonCollector_CollectArgs_Unable_to_find_a_column_named___0__,
                    conditionColumnName));
                return null;
            }

            ICollection<string> groups = new HashSet<string>();
            // The last line in the CSV file is empty, thus we compare length - 1
            for (int i = 1; i < lines.Length - 1; i++)
            {
                try
                {
                    groups.Add(lines[i].ParseCsvFields()[groupIndex]);
                }
                catch
                {
                    // ignore
                }
            }

            using (var dlg = new GroupComparisonUi(groups.ToArray(), oldArgs))
            {
                var result = parent != null ? dlg.ShowDialog(parent) : dlg.ShowDialog();
                if (result != DialogResult.OK)
                    return null;
                return dlg.Arguments;
            }
        }