public bool IsXml(string data, XmlTestDepth testDepth){ if (Is(testDepth,XmlTestDepth.FullValidation)) return TryReadAsXml(data); var startsWithElement = Regex.IsMatch(data, @"^(<\?xml[\s\S]+?\?>)?\s*<\w+[\s\S]+?/?>", RegexOptions.Compiled); var endsWithElement = Regex.IsMatch(data, @"<\w+[\s\S]*?/?>\s*$", RegexOptions.Compiled); return startsWithElement && endsWithElement; }
public static string WrapAsTextIfNeeded(string data, XmlTestDepth depth){ if (!XmlTestBase.GetIsXml(data, depth)) return WrapAsText(data); return data; }
public static bool GetIsXml(string data, XmlTestDepth depth){ return new XmlTestBase().IsXml(data, depth); }
public IXmlTest GetXmlTest(string data, XmlTestDepth testDepth, params object[] advancedParameters){ return this; }