Enumerating Property Bag Properties...

Dec 17, 2010 at 7:34 PM
Edited Dec 17, 2010 at 8:10 PM

I'm working on a simple management app for SPG Config items, and I'm trying to retrieve all the properties in an IPropertyBag instance, yet the interface doesn't appear to expose a collection.

IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
IConfigManager configManager = serviceLocator.GetInstance<IConfigManager>();
configManager.SetWeb(SPContext.Current.Web);
IPropertyBag bag = configManager.GetPropertyBag(ConfigLevel.CurrentSPSite);

How do I do the following?

foreach (???? prop in bag)
{
// do something with prop.value...
}

I get an enumeration error at design-time.  I could use the raw property bag SPContext.Current.Web.AllProperties, filtering by "PnP.Config.Key." as a prefix, but wouldn't that defeat the purpose of using the SPG?

Thanks,
Chris

Coordinator
Dec 18, 2010 at 5:41 PM

I agree this would be a useful feature for the future.  There isn't a way to do this other than going to a pretty low level as you describe.