I was talking to a friend of mine this afternoon, whom was asking me a bunch of questions around Silverlight and how it related to his Flex Development (he’s keen to take it out for a try). One thing that he did say that struck a chord with me and later with him, was the following comment:
“I get the XAML transparency thing which is good, but when I compile my Flash Applications it not only can compress my bitmaps but also the code base etc within“.
It’s a fair call to make, as with Flash when you do hit the compile, you can compress the entire payload in one hit (even override the jpg compression ratios etc).
Well not to be outdone, I pointed out that within Silverlight you can bring in .ZIP packages over the wire and the runtime can pick them apart and extract assets from them. It’s quite similar in many ways to how Flex uses Modules within (I stress the word similar, so Flex Zealots need not apply here).
This is done through the Downloader Object and to quote the documentation for it:
Silverlight provides the ability to download content as a package, which is a collection of independent files containing XAML content, media assets, and other application data. The Zip file format is supported as a download package. The following diagram illustrates a collection of application content contained within a Zip download package:
Once the package is successfully downloaded, you can use methods, such as GetResponseText, SetSource, and CreateFromXamlDownloader, to selectively retrieve a specific named part of the package. In this case, a part reference is the filename reference of the individual content within the package, such as “rotation01_green.png”.
This is very exciting stuff, as you could use this in a number of ways, specifically compressing XML data islands and so forth. Zip compression isn’t anything new and with enough caching / zip compression on HTTP headers one is able to reduce download rates as best they can – but – Silverlight has zip deserialization capabilities at runtime. I repeat, it has this ability at RUNTIME through basic API’s.
It just pays to read the manual as there is other goodies like this found within.