The Reactor pattern allows an application to handle concurrent events while retaining the simplicity of single-threading. In this example we will create a generic version of the Reactor Pattern, it gives us further abstraction of the business logic from the pattern which improves code reuse.

The Reactor Pattern is a design pattern for synchronous demultiplexing and dispatching of concurrently arriving events. It receives incoming messages/requests/connections from multiple concurrent clients and processes these messages sequentially using event handlers. Basically the Reactor pattern allows an application to handle concurrent events while retaining the simplicity of single-threading.

In this example we will integrate with the Rackspace Cloud Server API using C#. The Rackspace Request class handles the HTTP GET and POST process. You just tell it which REST end point you can to call. It then returns a object of type dynamic.

In this example we will Authenicate with the Rackspace API, by making a Http Request in which you set the User and Key values for API access. The response will include the both the Server Management Url and the Auth Token in it headers. The Auth Token is valid for 24 hours.

In this example we will convert a JSON String to ExpandoObject. Start with an extension method that takes the json string value and converts it into a IDictionary. Then we use an extension method which processes each key value pair into the Expando Object.

In this example we will convert an ExpandoObject to JSON string using an Extension method. This is done by looping over the key value pairs in the Expando Object and using the JavaScriptSerializer to serialize the value property.