.net - Registering instances with MEF -


I have to register an object instance in the container> T & gt; I can not use Normal ComposeExportedValue & lt since I do not know what T compile is on time

The method I need is something like this: container RegisterInstance. (Type someType, example objection)

Any ideas?

After the

Here is a version ComposeExportedValue is not that simple:

  Public static void ComposeExportedValue (This CompositionContainer Container, String ContractName, exportedValue Object) {If (Container == Faucet) New ArgumentNullException Throw ("Container"); If (exported value == empty) remove new logic ("exportedValue"); Compositionbatch batch = new compositionbatch (); Var metadata = new dictionary & lt; String, Object & gt; {{"ExportTypeIdentity", AttributedModelServices.GetTypeIdentity (exportedValue.GetType ())}}; Batch.adxport (new export (contract name, metadata, () => exported value); Container.Compose (batch); } Public static void ComposeExportedValue (The CompositionContainer Container, exportedValue Object) {If (Container == Faucet) New ArgumentNullException Throw ("Container"); If (exported value == empty) remove new logic ("exportedValue"); ComposeExportedValue (Container, AttributedModelServices.GetContractName (exportedValue.GetType (), exportedValue);}  

Comments