/// <summary> /// Creates a new instance based on xml configuration /// </summary> /// <param name="node">The node holding the configuration</param> /// <param name="throwOnMissing">Controls if an exception should be thrown if the attributes are missing</param> /// <returns>A new initialized instance or null</returns> public static ThresholdSettings CreateFromXML(XmlNode node, bool throwOnMissing = true) { ThresholdSettings result = null; if (node.Attributes.Count >= ThresholdSettings.AttributesCount) { result = new DTWRecognizer.ThresholdSettings() { FirstThreshold = double.Parse(node.Attributes["firstThreshold"].Value), MatchThreshold = double.Parse(node.Attributes["matchThreshold"].Value), MaxSlope = double.Parse(node.Attributes["maxSlope"].Value) } } ; else if (throwOnMissing) { throw new InvalidDataException("Invalid number of attributes"); } return(result); }
/// <summary> /// Overrides the equality operator /// </summary> /// <param name="obj">The object to compare with</param> /// <returns>True if the objects are equal, otherwise false</returns> public override bool Equals(object obj) { bool result = false; if (obj == null || obj as DTWRecognizer.ThresholdSettings == null) { result = false; } else if (object.ReferenceEquals(this, obj)) { result = true; } else { DTWRecognizer.ThresholdSettings other = obj as DTWRecognizer.ThresholdSettings; result = this.FirstThreshold == other.FirstThreshold && this.MatchThreshold == other.MatchThreshold && this.MaxSlope == other.MaxSlope; } return(result); }