Ewl » Canonical The canonical version of EWL Read More
Clone URL:  
EwfSafeRequestHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System; using EnterpriseWebLibrary.DataAccess; namespace EnterpriseWebLibrary.EnterpriseWebFramework { /// <summary> /// An object that handles a safe HTTP request (e.g. GET, HEAD). /// </summary> public sealed class EwfSafeRequestHandler { public static implicit operator EwfSafeRequestHandler( EwfSafeResponseWriter responseWriter ) { return new EwfSafeRequestHandler( responseWriter ); } private readonly EwfSafeResponseWriter responseWriter; /// <summary> /// Creates a request handler from the result of the specified data-modification method. If you do not need to modify data, do not call this constructor; /// use <see cref="EwfSafeResponseWriter"/>, which can be implicitly converted to a request handler. /// </summary> public EwfSafeRequestHandler( Func<EwfSafeResponseWriter> dataModificationMethod ) { DataAccessState.Current.DisableCache(); try { responseWriter = dataModificationMethod(); } finally { DataAccessState.Current.ResetCache(); } } private EwfSafeRequestHandler( EwfSafeResponseWriter responseWriter ) { this.responseWriter = responseWriter; } internal void WriteResponse() { responseWriter.WriteResponse(); } } }