void IRequestLog.TraceRuleListEnd(IRequestInfo request, IRuleList ruleList, IRuleListResult ruleListResult) { ReduceIndent(); Output( ruleList.ToString(request), (ruleListResult.RuleResults != null && ruleListResult.RuleResults.Count > 0 ? ruleListResult.RuleResults.Count + " rules evaluated." : ""), (ruleListResult.StopProcessing ? "Stop processing." : ""), (ruleListResult.EndRequest ? "End request." : "")); }
public Script( IFactory factory, Stream stream, Encoding encoding, bool incoming) { _factory = factory; _incoming = incoming; _customTypeRegistrar = new CustomTypeRegistrar(_factory); XDocument document; try { using (var reader = new StreamReader(stream, encoding)) document = XDocument.Load(reader); } catch (Exception ex) { throw new Exception("Failed to load url rewrite script as XDocument", ex); } var xmlRoot = document.Root; if (xmlRoot == null) { throw new Exception("No root element in url rewrite script"); } if (xmlRoot.Name != "rewrite") { throw new Exception("The rewriter rules must be an XML document with a <rewrite> root element"); } var context = new ParserContext(); foreach (var element in xmlRoot.Elements()) { if (element.Name.LocalName.ToLower() == "rewritemaps") { ParseRewriteMaps(element, context); } else if (element.Name.LocalName.ToLower() == "rules") { _rules = ParseRulesElement(element, context, "Root"); } } }
/// <summary> /// Takes a set of rules and writes a description of them into a stream /// </summary> /// <param name="rules">The rules to describe</param> /// <param name="stream">The stream to write the description into</param> /// <param name="encoding">The encoding to use when writing text to the stream</param> public static void DescribeRules( IRuleList rules, Stream stream, Encoding encoding) { var writer = new StreamWriter(stream, encoding); if (rules == null) { writer.Write("There is no spoon"); } else { rules.Describe(writer, "", " "); } writer.Flush(); // Note, do not dispose or close the writer unless it owns the stream. }
void IRequestLog.TraceRuleListBegin(IRequestInfo request, IRuleList ruleList) { Output(ruleList.ToString(request)); IncreaseIndent(); }
public static void SetRules(IRuleList rules) { _rules = rules; }