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

How can I create a property export in C#?

Feb 10, 2011 at 3:56 AM
Edited Feb 10, 2011 at 3:56 AM

I need to define a property export (which behaves as a poor man's factory as every call to import calls the getter), at runtime. I can't define it via attributes as it is an abstract class and some framework stuff I have no control over expects a standard export definition (not a func export). 

I can simulate an regular export easy enough:


var metadata = new Dictionary<string, object>

                metadata.Add(CompositionConstants.PartCreationPolicyMetadataName, CreationPolicy.NonShared);

                var export = new Export(contractName, metadata, () => { 

			return GetProvider()



But how would I simulate a property export?