by jesseliberty via Jesse Liberty - Silverlight Geek on 1/11/2010 3:40:00 PM
[ Jan 23 - Note that the design specified here has been significantly updated ]
In the spirit of a glass-house (you get to see everything as it happens), open source project, here is a draft of how I see handling configuration for the Silverlight HyperVideo Platform -- this will be modified in the next iteration to take more advantage of the services provided by MEF.
It doesn’t matter what order the modules are loaded by MEF.
Maximum encapsulation, minimal coupling
EventManager
Rather than having objects publish and subscribe directly, this will be mediated by what for now I’m calling an EventManager. This object may be build on Prism’s event aggregator, and may take more advantage of MEF’s ability to provide services.
When, below, I talk about a module firing an event, what I actually envision is that the object firing the event calls a method on the EventManager, which in turn first the event (objects subscribe with the EventManager)
Known Events In a subsequent version, the EventManager won’t necessarily know in advance all the events it must manage but right now I assume it does. The known events are:
Modules & Core Abstract Clases
While any number of modules may be loaded into the SLHVP, we initially anticipate that there will be modules deriving from the following abstract classes
Application startup
On startup, the Viewer is instantiated and is given the initial configuration file’s url. It subscribes to ICareAboutItemLists and HereIsANewLink. It then uses the configuration file to determine which Frame to instantiate.
When a Frames instantiated it subscribes to HereAreTimeObjects, HereIsAnItem, SeekTo, and fires off ICareAboutTimeObjects
When the ItemsList module is instantiated it subscribes to HereIsAnItemsList and fires of ICareAboutItemLists
When the LocationList module is instantiated it subscribes to HereIsAnItem, and fires off ICareAboutItems
When the LinksList module is instantiated it subscribes HereIsAnItem and LocationReached and fires off ICareAboutItems
ICareAboutItemLists
When ICareAboutItemLists is raised, the Viewer responds by raising HereIsAnItemsList and passing the config file url in the event args. That file has the list of items to display and the url of the config file for each item
HereIsAnItemsList The ItemsList module responds to HereIsAnItemsList by reading the config file, creating its list of items, and storing the url of the config file for each item. It then raises HereIsAnItem
HereIsAnItem HereIsAnItem is responded to by LocationList, which read the config file. LocationList creates all its links as an internal object, and displays them
This event is also responded to by LinksList, which examines the configuration and may find markers or time elements. If it finds neither, it has nothing to do. If it finds markers, it makes a collection of the markers so that it can respond to LocationReached. If it finds Time elements it creates a collection of TimeObjects and fires off HereAreTimeObjects.
The frame also responds to HereIsAnItem by loading the item in the URL in the EventArgs and displaying that item
HereAreTimeObjects
The Frame responds to HereAreTimeObjects by getting the TimeObjects out of the EventArgs and adding them to its own TimeObjects collection.
MarkerEvents
When the Frame hits a marker, it fires the LocationReached event, providing a Location object which has the time elapsed When the frame reaches a time that corresponds to one of its TimeObjects it:
LocationReached
LinksItem responds to LocationReached by putting up its appropriate link
User Clicks On A Link (SeekTo, and Links) When the user clicks on a link in LocationsItem, the module raises the SeekTo event. The Frame responds to SeekTo as you would expect.
When the user clicks on a Links module link, it fires the HereIsANewLink, with the url of the config file for that link
HereIsANewLink When the HereIsANewLink event is fired, the Viewer responds, chases the URL and fires off HereIsAnItemsList (see above for the Items response)
Original Post: Severely Decoupled Configuration
The content of the postings is owned by the respective author. Silverlight Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on Silverlight Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.