How it works...

The Discovery pattern is a great way to allow your application to set itself up. In other words, your application can look for the data it needs by raising an event. Subscribers to that event will then provide the requested data.

This allows for a very dynamic way of extending your application, while still maintaining control over what your application does.

The pattern begins by raising an event in your code at the point where you need the desired data. Typically, you would use a temporary table in the event so that the subscribers can insert their data into it. Once all the subscribers have executed, the resulting data that they provided can then be processed by your application.

Another, maybe more entertaining way of thinking of this pattern is the following conversation between the main application (for example, your application) and three custom applications that are installed in the same system:

Main Application: Hey everyone, I need some data for this routine I'm about to run. Does anyone have it?
Custom Application 1: Yes, here is some data for you.
Custom Application 2: <no reply>
Custom Application 3: I sure do! Here is some data for your routine.
Main Application: Thanks, I'll carry on now and do the routine now!
Care should be taken when subscribing to the Discovery pattern event.

You should never assume that you're the only subscriber, so make sure to create unique records by using GUIDs and prefixes that another application won't duplicate, and if that happens, handle it accordingly.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.168.8