I have a class with an IList<T>
property decorated with the [ImportMany(allowRecomposition = true)]
attribute. There are some conditions in which the application might not find any available Exports of the requested type. Right now, it's throwing a CompositionException if no Exports of the requested type are found. I dislike application flow being determined by thrown exceptions, so I would rather not catch and react in this case. Rather, I just want program execution to continue.
Is there a flag or something I can set to make this Import optional? I know for single import properties, you can do this: [Import(AllowDefault = true)]
but 'AllowDefault
' is not an option on the ImportMany
attribute.