Tuesday, March 24, 2009
Creating Playlists With Linq - Another Great Use For CodeDomProvider
I recently found a new use for dynamically-compiled assemblies using CodeDomProvider. Combined with Linq, it enables the ultimate flexibility in music playlist generation.
My "Code Playlists", are snippets of code that can do whatever they want as long as they return an enumerable collection of song objects. As you can see above, simple Linq expressions make it really easy to generate pretty much any collection of songs that my music metadata can support.
Subscribe to:
Post Comments (Atom)
Hi,
ReplyDeleteim interested your article about create PLaylist with Linq .Do you have a code snippet for that.
Thanks in advantage.
You can find some code for the core technique here:
ReplyDeleteDynamically Compiling Assemblies with CodeComProvider
You don't have to do anything particularly special to use Linq, except that you need to make sure you are targeting the approperiate version of .NET:
var providerOptions = new Dictionary<string, string>();
providerOptions.Add("CompilerVersion", "v3.5");
codeProvider = new CSharpCodeProvider(providerOptions);
and make sure that your assembly code has a "using System.Linq;" in it.