-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathEventsModule.cs
43 lines (38 loc) · 1.46 KB
/
EventsModule.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
38
39
40
41
42
43
using System;
using System.Web;
namespace ModulesLibrary
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Source shared with .NET Framework that does not have the method")]
public class EventsModule : BaseModule
{
public const string End = "end";
public const string Complete = "complete";
public const string Throw = "throw";
protected override void InvokeEvent(HttpContext context, string name)
{
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
if (context.CurrentNotification == RequestNotification.BeginRequest)
{
context.Response.ContentType = "text/plain";
}
context.Response.Output.WriteLine(name);
if (string.Equals(name, context.Request.QueryString["notification"], StringComparison.OrdinalIgnoreCase))
{
switch (context.Request.QueryString["action"])
{
case End:
context.Response.End();
break;
case Complete:
context.ApplicationInstance.CompleteRequest();
break;
case Throw:
throw new InvalidOperationException();
}
}
}
}
}