Exemplo n.º 1
0
 /// <summary>
 /// Returns a list of regexs used to evaluate the handler to see if it can
 /// be used to handle the requested useragent.
 /// </summary>
 /// <param name="reader">The XML stream reader.</param>
 /// <returns>A list of regexes.</returns>
 private static List<HandleRegex> ProcessRegex(XmlReader reader)
 {
     List<HandleRegex> regexs = new List<HandleRegex>();
     while (reader.Read())
     {
         if (reader.Depth > 0 && reader.IsStartElement("regex"))
         {
             HandleRegex regex = new HandleRegex(reader.GetAttribute("pattern"));
             regex.Children.AddRange(ProcessRegex(reader.ReadSubtree()));
             regexs.Add(regex);
         }
     }
     return regexs;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Reads the regular expressions used to determine if the user agent can be handled
 /// by the handler.
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="list"></param>
 private static void ReadHandlerRegexes(BinaryReader reader, List<HandleRegex> list)
 {
     int count = reader.ReadInt16();
     for (int i = 0; i < count; i++)
     {
         string pattern = reader.ReadString();
         HandleRegex regex = new HandleRegex(pattern);
         ReadHandlerRegexes(reader, regex.Children);
         list.Add(regex);
     }
 }