private IntRestriction CreatIntResriction(IXmlVisitorBase node) { IntRestriction res = new IntRestriction(); try { if (node.Name == "INT") { res.max = int.Parse(node.GetAttribute("MAX")); res.min = int.Parse(node.GetAttribute("MIN")); return(res); } throw new Exception(); } catch { throw new Exception($"{node.ToString()} is invalide. IntRestriction should be <INT MAX=\"16383\" MIN=\"1\"/>"); } }
private bool ValidateValue(string value, IEnumerable <XmlVisitor> resnodes) { string log = ""; foreach (var res in resnodes) { if (res.Name == "INT") { IntRestriction intrange = CreatIntResriction(res); if (true == intrange.validate(value)) { return(true); } log += res.ToString(); } else { throw new Exception($"Restriction {res.ToString()} is unknown."); } } TraceMethod.Record(TraceMethod.TraceKind.WARNING, $"{value} is invalid of restriction {log}"); return(false); }