public CoverageThreshold(CoverageViewElementType type, CoverageMetric stat, float statValue, string name) : this(type, stat, statValue) { if ((name != null) && (name.Trim() == "*")) { name = string.Empty; } this.Pattern = name; }
public static CoverageThreshold Parse(string threshold) { if (string.IsNullOrEmpty(threshold)) { throw new ArgumentNullException("threshold"); } string[] strArray = threshold.Split(new char[] { ':' }, StringSplitOptions.None); CoverageThreshold threshold2 = new CoverageThreshold(); if (strArray.Length > 0) { threshold2.CoverageType = (CoverageMetric)Enum.Parse(typeof(CoverageMetric), strArray[0]); if (strArray.Length <= 1) { return(threshold2); } float actualValue = float.Parse(strArray[1]); if (actualValue < 0f) { throw new ArgumentOutOfRangeException("statValue", actualValue, "Parameter 'statValue' must be greater than or equal to 0.0 Was: " + actualValue.ToString()); } if ((threshold2.CoverageType != CoverageMetric.CyclomaticComplexity) && (actualValue > 100f)) { throw new ArgumentOutOfRangeException("statValue", actualValue, "Parameter 'statValue' must be less than or equal to 100.0 Was: " + actualValue.ToString()); } threshold2.Value = actualValue; if (strArray.Length <= 2) { return(threshold2); } CoverageViewElementType type = (CoverageViewElementType)Enum.Parse(typeof(CoverageViewElementType), strArray[2]); switch (type) { case CoverageViewElementType.Unknown: case CoverageViewElementType.InstrumentedPoint: case CoverageViewElementType.Method: case CoverageViewElementType.Property: throw new ArgumentOutOfRangeException("type", type, "Parameter 'type' had an invalid value: " + type.ToString()); } threshold2.ElementType = type; if (strArray.Length > 3) { string pattern = strArray[3].Trim(new char[] { '\'', '"' }); new Regex(pattern); threshold2.Pattern = pattern; if (strArray.Length > 4) { threshold2.IsMaxThreshold = !string.IsNullOrEmpty(strArray[4]) && strArray[4].Equals("true", StringComparison.InvariantCultureIgnoreCase); } } } return(threshold2); }
public CoverageThreshold(CoverageViewElementType type, CoverageMetric stat, float statValue) { if (statValue < 0f) { throw new ArgumentOutOfRangeException("statValue", statValue, "Parameter 'statValue' must be greater than or equal to 0.0 Was: " + statValue.ToString()); } if ((stat != CoverageMetric.CyclomaticComplexity) && (statValue > 100f)) { throw new ArgumentOutOfRangeException("statValue", statValue, "Parameter 'statValue' must be less than or equal to 100.0 Was: " + statValue.ToString()); } if (((type == CoverageViewElementType.Unknown) || (type == CoverageViewElementType.InstrumentedPoint)) || ((type == CoverageViewElementType.Method) || (type == CoverageViewElementType.Property))) { throw new ArgumentOutOfRangeException("type", type, "Parameter 'type' had an invalid value: " + type.ToString()); } this.Value = statValue; this.ElementType = type; this.CoverageType = stat; }