private IEnumerable <ISpecificationElement> GetSpecifications(Assembly assembly, string xml) { var document = XDocument.Parse(xml); var cache = new DiscoveryCache(assembly); foreach (var contextElement in document.Descendants("contextinfo")) { token.ThrowIfCancellationRequested(); var contextInfo = ContextInfo.Parse(contextElement.ToString()); var contextIgnore = cache.GetIgnoreReason(contextInfo.TypeName); var context = contextInfo.ToElement(contextIgnore); foreach (var specificationElement in contextElement.Descendants("specificationinfo")) { token.ThrowIfCancellationRequested(); var specification = SpecificationInfo.Parse(specificationElement.ToString()); var behavior = specification.IsBehavior(context.TypeName) ? cache.GetOrAddBehavior(context, specification) : null; var specificationIgnore = behavior != null ? cache.GetIgnoreReason(behavior.TypeName, specification.FieldName, false) ?? behavior.IgnoreReason : cache.GetIgnoreReason(context.TypeName, specification.FieldName, true); yield return(SpecificationInfo.Parse(specificationElement.ToString()) .ToElement(context, specificationIgnore, behavior)); } } }
private void OnListenEvent(string value) { using (var stringReader = new StringReader(value)) { XDocument doc = XDocument.Load(stringReader); XElement element = doc.XPathSelectElement("/listener/*"); switch (element.Name.ToString()) { case "onassemblystart": _runListener.OnAssemblyStart(AssemblyInfo.Parse(element.XPathSelectElement("//onassemblystart/*").ToString())); break; case "onassemblyend": _runListener.OnAssemblyEnd(AssemblyInfo.Parse(element.XPathSelectElement("//onassemblyend/*").ToString())); break; case "onrunstart": _runListener.OnRunStart(); break; case "onrunend": _runListener.OnRunEnd(); break; case "oncontextstart": _runListener.OnContextStart(ContextInfo.Parse(element.XPathSelectElement("//oncontextstart/*").ToString())); break; case "oncontextend": _runListener.OnContextEnd(ContextInfo.Parse(element.XPathSelectElement("//oncontextend/*").ToString())); break; case "onspecificationstart": _runListener.OnSpecificationStart(SpecificationInfo.Parse(element.XPathSelectElement("//onspecificationstart/*").ToString())); break; case "onspecificationend": _runListener.OnSpecificationEnd( SpecificationInfo.Parse(element.XPathSelectElement("//onspecificationend/specificationinfo").ToString()), Result.Parse(element.XPathSelectElement("//onspecificationend/result").ToString())); break; case "onfatalerror": _runListener.OnFatalError(ExceptionResult.Parse(element.XPathSelectElement("//onfatalerror/*").ToString())); break; } } }