This repository has been archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
eventbrokersimplifiedhandlermethods.html
83 lines (80 loc) · 2.46 KB
/
eventbrokersimplifiedhandlermethods.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
layout: documentation
title: EventBroker
teaser: Decoupled eventing with automatic thread switching
navigation:
- name: Overview
link: eventbroker.html
- name: Tutorial
link: eventbrokertutorial.html
- name: Registration by Attribute
link: eventbrokerregistrationbyattribute.html
- name: Registration over Interface
link: eventbrokerregistrationoverinterface.html
- name: Registration by Registrar
link: eventbrokerregistrationbyregistrar.html
- name: Simplified Handler Methods
link: eventbrokersimplifiedhandlermethods.html
- name: Direct Interaction
link: eventbrokerdirectinteraction.html
- name: Handlers
link: eventbrokerhandlers.html
- name: Matchers
link: eventbrokermatchers.html
- name: Exception Handling
link: eventbrokerexceptionhandling.html
- name: Extensions
link: eventbrokerextensions.html
- name: Logging
link: eventbrokerlogging.html
- name: Testability
link: eventbrokertestability.html
- name: Tips and Tricks
link: eventbrokertipsandtricks.html
- name: Specifications
link: eventbrokerspecifications.html
---
<h2>Simplified Handler Methods</h2>
<p>
Standard .Net event handler methods have a signature with a sender and an event args.
</p>
<p>
For example:
</p>
<script type="syntaxhighlighter" class="brush: csharp"><![CDATA[
public void HandleSomeEvent(object sender, SomeEventArgs eventArgs);
]]></script>
<h3>Omit <code>sender</code> Argument</h3>
<p>
Most of the times, the sender is not relevant to the handling method.
</p>
<p>
Therefore you can simplify the signature to:
</p>
<script type="syntaxhighlighter" class="brush: csharp"><![CDATA[
public void HandleSomeEvent(SomeEventArgs eventArgs);
]]></script>
<p>
The event broker will still call this handler method. It just omits the <code>sender</code> argument.
</p>
<h3>Automatically extract Generic Event Arguments</h3>
<p>
When using <code>EventArgs<T></code>, you can omit the <code>EventArgs</code>, too.
</p>
<p>
Instead of
</p>
<script type="syntaxhighlighter" class="brush: csharp"><![CDATA[
public void HandleSomeEvent(EventArgs<string> eventArgs);
]]></script>
<p>
you can write
</p>
<script type="syntaxhighlighter" class="brush: csharp"><![CDATA[
public void HandleSomeEvent(string value);
]]></script>
<p>
<p>
<i>Note</i> that this works only with the <code>Appccelerate.EventArgs<T></code>.
But we have plans to allow custom extractors to be registered in the future.
</p>