[CA-220457] Move the match Regex objects to be static class objects

Moved from BuildList method to the GraphHelpers class. Since they're only used in this class for this search, and there's similar but broader Regex objects in the Helpers class that are used for parsing, I think it's better to keep them in this class to avoid confusion.

Signed-off-by: Callum McIntyre <callumiandavid.mcintyre@citrix.com>
This commit is contained in:
Callum McIntyre 2016-10-27 10:41:44 +01:00
parent 173149b749
commit fd46c9b24e

View File

@ -172,6 +172,9 @@ namespace XenAdmin.Controls.CustomDataGraph
public static class DataSourceItemList public static class DataSourceItemList
{ {
private static Regex io_throughput_rw_regex = new Regex("^io_throughput_(read|write)_([a-f0-9]{8})$"); // old SR read/write datasources
private static Regex sr_rw_regex = new Regex("^(read|write)_([a-f0-9]{8})$"); // replacement SR read/write datasources
public static List<DataSourceItem> BuildList(IXenObject xenObject, List<Data_source> dataSources) public static List<DataSourceItem> BuildList(IXenObject xenObject, List<Data_source> dataSources)
{ {
List<DataSourceItem> dataSourceItems = new List<DataSourceItem>(); List<DataSourceItem> dataSourceItems = new List<DataSourceItem>();
@ -194,9 +197,6 @@ namespace XenAdmin.Controls.CustomDataGraph
} }
// Filter old datasources only if we have their replacement ones // Filter old datasources only if we have their replacement ones
Regex io_throughput_rw_regex = new Regex("^io_throughput_(read|write)_([a-f0-9]{8})$"); // old datasources
Regex sr_rw_regex = new Regex("^(read|write)_([a-f0-9]{8})$"); // replacement datasources
if (dataSourceItems.Any(dsi => sr_rw_regex.IsMatch(dsi.DataSource.name_label))) if (dataSourceItems.Any(dsi => sr_rw_regex.IsMatch(dsi.DataSource.name_label)))
{ {
// Remove any old style data sources // Remove any old style data sources