This project has moved and is read-only. For the latest updates, please go here.

building exports on the fly

Aug 27, 2009 at 10:44 PM

I want to be able to export things in a data driven way.

For example imagine that I have a database. For each row in a given table I want to create an export that an importer wil be able to enumerate (the actual use case is a directory full of scripts)

I can see that I could use ref.emit to build an assembly from scratch but that seems like a lot of heavy lifting.





Aug 27, 2009 at 10:57 PM

Have you considered CompositionContainer.ComposeExportedValue()? I think this is probably what you're looking for.



Aug 28, 2009 at 9:02 AM

pm100, you may also want to look into our ExportProvider. ExportProvider provides a way for you to add custom sources of exports into the container. You could for example have an EP that queries a DB and then manufactures exports on the fly for each record.

This post covers the basics.



Aug 28, 2009 at 6:34 PM

i see how those work . thx

what would be nice would be for the module developer to be able to do this in an assembly without the hosting app having to explicitly deal with it.

I can imagine a new Export attribute that says


And when the assembly catalog sees this it instatiates it immediately and then calls a specifc interface on it that willl enumerate the actual exports. The exports would be described by properties rather than metadata attributes



Aug 29, 2009 at 6:31 PM

I just wrote a long post because I'm doing something almost hte same, but what you're doing actually sounds simpler.

Why not just have a plain part that exposes an IEnumerable<IDataRow> as a method? That method can do whatever it likes to fulfille the contract. It's not obvious to me why you would need a catalog.

Or if its the scripts you want to enumerate, a method that returns IEnumerable<IScriptItem>?