Saturday, August 25, 2007

Where to store global properties?

Before sharepoint, we used the web.config to store properties. Then in the global.cs, we would store them as application variables (Application["Name"] = ConfigurationSettings.AppSettings["NameValue"];). If we wanted to update the properties, we would have to make the change to the web.config. We all know what happens when you do that.

What I did in Sharepoint (Only because I don't know of a better way. Advice is welcomed) is create a new class called GlobalProperties and based it off of ConfigurationSection. In the constructor, I'm calling a method that reads from a list and stores the name/value of the items in a ConfigurationPropertyCollection. I've also setup a method that will reset the collection since the constructor is only called one time.

I'm not sure this is the best way to do it, but it made sense to me.

No comments: