I have a class in a web application I'm working on that contains client settings. For some background, I do not own this class, and changing it is not an option. Recently, we added some logic to store the settings in the database, and I was instructed to create a page for editing them, fairly fair.
Here is my problem; settings are stored in a static class and are themselves static, read-only. for instance
public static class Settings { public static readonly setting1 = SettingmanagerClass.GetSetting("setting1"); public static readonly setting2 = SettingmanagerClass.GetSetting("setting2"); public static readonly setting3 = SettingmanagerClass.GetSetting("setting3"); }
Now, for example, on the page I wrote, we change the value for parameter2 to "Happy variable"; it saves the database just fine, but now I need it to be reflected in the web application as a new value. Since this is a static readonly property of a static class, it is only ever called when the application first connects and cannot be manually installed.
To repeat, I do not have the original class, so "just create properties that can be written" is not (currently) valid. Usually I just talk about it with my boss, and he makes a decision and maybe allows me to change another class, but I am not able to make this call and it does not work for a week.
So basically; is there any way to reinitialize a static class after launching a web application? I just need to reload all its properties, as if the application was just rebuilt and started again.
source share