Esempio n. 1
0
 private static void SetRecordWriter(this HtmlHelper html, RecordWriter writer)
 {
     RecordWriter existWriter = html.ViewContext.HttpContext.Items[RecordWriterKey] as RecordWriter;
     if (existWriter != null)
     {
         throw new InvalidOperationException("RecordWriter 已经存在,可能页面已经被缓存了");
     }
     html.ViewContext.HttpContext.Items[RecordWriterKey] = writer;
 }
Esempio n. 2
0
 /// <summary>
 /// 创建用于片断缓存的 <see cref="RecordWriter"/>
 /// </summary>
 /// <param name="html"></param>
 /// <param name="writer"></param>
 /// <returns></returns>
 public static TextWriter CreateCacheWriter(this HtmlHelper html, TextWriter writer)
 {
     RecordWriter recordWriter = new RecordWriter(writer);
     html.SetRecordWriter(recordWriter);
     return recordWriter;
 }