I have a site scoped Feature which specifies a list as such:
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <ListInstance Title="Test List" OnQuickLaunch="FALSE" TemplateType="101" FeatureId="<snip>" Url="Lists/TestList" Description=""> </ListInstance> </Elements>
This feature may be activated in multiple site collections and the contents of the list may be modified independently in each site collection.
What I'm trying to do is to allow changes in each site collection to be persisted when the feature is deactivated then reactivated and the list removed altogether when the feature is uninstalled.
My initial attempt was to use a SPFeatureReceiver but I'm having trouble getting the exact behavior I'm seeking.
I can't remove the list when the feature is deactivated because it will lose any customizations if the feature is ever reactivated.
I attempted to remove the list in FeatureUninstalling but I'm not sure how to access all instances of the list in all site collections to remove it. Do I need to iterate over every site collection and remove the list if its present? If so, how can I list of all the site collections that exist?