This project has moved. For the latest updates, please go here.

Assistant with creation policies

Feb 3, 2011 at 2:27 PM

I have a quick (yet very important) question related to CreationPolicy.  If I set a property (that is ImportMany) with a RequiredCreationPolicy of "Any" will it be able to store objects that are both Shared and Non-Shared.  For example, if the property in question imports interface IBlah and I have two classes that inherit IBlah, can ClassA : IBlah be Shared and ClassB : IBlah be Non-Shared? or must they both be the same?

Feb 3, 2011 at 3:37 PM
Edited Feb 3, 2011 at 3:38 PM

Since CreationPolicy.Any is the default value it doesn't matter if you apply it to a property.

If you set PartCreationPolicy you either specify Shared or NonShared.

I suggest you try this yourself by creating a test project where you can test intrinsic behavior like this in a controlled setting.

Feb 3, 2011 at 3:45 PM

"I don't know" would have worked.

Feb 3, 2011 at 3:51 PM

I was able to complete my test application and it seems that you can specify both Shared and Non-Shared parts if the importing property is set to "Any".