public Stream Fortunes()
        {
            var ctx      = GetContext(Services);
            var fortunes = ctx.FortuneRepository.Search();
            var list     = new List <KeyValuePair <int, string> >(fortunes.Length + 1);

            foreach (var f in fortunes)
            {
                list.Add(new KeyValuePair <int, string>(f.id, f.message));
            }
            list.Add(new KeyValuePair <int, string>(0, "Additional fortune added at request time."));
            list.Sort(Comparison);
            var cms      = ctx.Stream;
            var writer   = cms.GetWriter();
            var template = new Fortunes(list, writer);

            template.TransformText();
            writer.Flush();
            cms.Position = 0;
            ThreadContext.Response.ContentType = "text/html; charset=UTF-8";
            return(cms);
        }
 public Stream Fortunes()
 {
     var ctx = GetContext(Services);
     var fortunes = ctx.FortuneRepository.Search();
     var list = new List<KeyValuePair<int, string>>(fortunes.Length + 1);
     foreach (var f in fortunes)
         list.Add(new KeyValuePair<int, string>(f.id, f.message));
     list.Add(new KeyValuePair<int, string>(0, "Additional fortune added at request time."));
     list.Sort(Comparison);
     var cms = ctx.Stream;
     var writer = cms.GetWriter();
     var template = new Fortunes(list, writer);
     template.TransformText();
     writer.Flush();
     cms.Position = 0;
     ThreadContext.Response.ContentType = "text/html; charset=UTF-8";
     return cms;
 }