in

WPF Design and Development

IdentityMine Team Blogs

David Kelley

A day in the life of a humble software architect... doing C#, WPF, Silverlight, Legos, Fuzzy Logic AI and/or whatever is the latest and greatest or more importantly the coolest techo mumbo jumbo...

Silverlight, JSON and Automatic Design Asset Zip and index generation...

Lets say we have a huge silverlight application.  And lets say that we have a lot of images, xaml and media that we use in our application.  Silverlight does a great job of allowing us to use downloaders and catch events and deal with it but lets say we want to just do it once.  Download everything in one file and then apply our assets.  We also don't want all of the loose assets floating around our Silverlight apps directory structure...

From an architectural stand point this is a much cleaner method of keeping additional assets packaged especially when there is a lot of xaml and images etc and keep it as small as possible over the wire.  Silverlight allows us to address all that by being able to download zip files.  On the downside there is not dynamic way to know what is in the zip file and plus it is a pain to have to do it on your own.  So this is how I addressed it. 

First I built a windows application project in Visual Studio without any windows.  I added directories with all my design assets and set them to be content and show up in the output directory.  When you compile the project it builds out the executable and copies all the folders and assets added to the project to the output directory.  From here Visual Studio starts the application.  Although it doesn't have a UI persay it starts by looking for any zips that might be in the directory and deletes them. 

Now the cool part happens...  it looks at all the diretories and creates an index JSON file for each folder.  It saves these all in the root of each directory and then proceeds to create zip files for each directory automatically.  All I need todo is then have this projects zip files that are generated in the output folder be copied to my Silverlight project directory structure as a pre or post build event and I'm good.  All these additional assets are kept nicely packaged and out of the main project.  And I didn't have to mess with it on my own.

 Also note that the attached project doesn't have the zip.exe that builds the zip via console commands passed to it.  You can use the command line version of any thing like pkzip etc but you will have to edit the source of the main application to make it work.  I have my own licensed copy of this command line tool that (pkzipc.exe) which is what the argument structure is designed for.

Comments

No Comments

About david.kelley

David for the past 10 years has focused on distributed application design and emerging Microsoft technologies on the web. Having helped design and build some of the largest systems for companies like Microsoft, Onyx Software, Saltmine, Giordanous Group and more and of course our favorite company Identitymine, he has been on the leading edge of applying the latest tech to real world business problems. David’s technology breadth includes everything from SQL Server to Windows/WCF and Silverlight. David’s accomplishments also include developing new technologies such as self editing XML files and related XML technologies to fuzzy logic systems and advanced web user interface design.
© 2007 IdentityMine, Inc.
Powered by Community Server (Commercial Edition), by Telligent Systems