Metadata attributes on Import contracts needed

Sep 13, 2008 at 7:34 AM

Now accessing ExportMetadata makes possible to adapt contracts in many-to-one scenario. I think in some cases it would be great to be able to get Import's metadata to choose the exact Import point I should inject into - many-to-many. Let's say I have got two versions of the same component, both are versioned using export metadata, there are five places where I use this component and I implemented a contract adapter that always inserts the latest version, but in one place I always want to have the first "default" version to be injected.

I've thought about several things how I can get it working...
Firstly I've thought about metadata attributes on import contracts so I'm able to get them in contract adapter. Then I remembered an idea of string contract naming like

[Export( "ContractA.V1" )]    // similar to [Export( "ContractA" ), ExportMetadata( "Version", "V1" )]
[Export( "ContractA.V2" )]

[Import( "ContractA.*" )]      // any as it is now, contract adapter is required
[Import( "ContractA.V1" )]   // only the first can be injected

It's all about string contracts, they are really valuable in comparison to strongly typed.
Sep 14, 2008 at 7:52 PM
Thanks Leonid

Is this for versioning, or where I have different types of things I'd like to use? For eample I would like to specify metadata key / values on import to choose a specific one from a list to be injected in one scenario for another. Something like this....

[ImportMetadata("Type", "In-Memory")

[ImportMetadata("Type", "Distributed")

in the case of having multiple Cache implementations.

For the versioning case we do have Contract Adapters. They can adapt one contract to another. In this case the contract would still be the same.....