Click here to Skip to main content
15,920,438 members
Home / Discussions / C#
   

C#

 
GeneralRe: Image-Listbox Pin
jphuphilly1-Jul-03 7:27
jphuphilly1-Jul-03 7:27 
GeneralRe: Image-Listbox Pin
jphuphilly30-Jun-03 11:35
jphuphilly30-Jun-03 11:35 
Questionwho knows sth. about FolderNameEditor? Pin
gongxiancao30-Jun-03 2:48
gongxiancao30-Jun-03 2:48 
GeneralToolbars, main menus & context menus Pin
hbandarra29-Jun-03 23:48
hbandarra29-Jun-03 23:48 
GeneralRe: Toolbars, main menus & context menus Pin
hbandarra30-Jun-03 3:19
hbandarra30-Jun-03 3:19 
GeneralDeserializing dynamically loaded types Pin
Oyvind Bratland29-Jun-03 22:26
Oyvind Bratland29-Jun-03 22:26 
Generalopacity of panels Pin
Member 138827529-Jun-03 21:39
Member 138827529-Jun-03 21:39 
QuestionSerialize into the appropriate App.exe.config file? Pin
Anonymous29-Jun-03 17:59
Anonymous29-Jun-03 17:59 
Please take a look at this article on devhood, http://www.devhood.com/messages/message_view-2.aspx?thread_id=70534

What I want to do is essentially have a class which contains all static members of my applications settings and have it serialized out.

Something along the lines of this,

class MySettings
{
public static bool isConstant;
public static bool doReports;
}

After serialization using the XmlSerializer class, I hope to get something like this,

<?xml version="1.0"?>
<appSettings>
<add name="isConstant" value="true">
<add name="doReports" value="false">
</appSettings>

The main reason for serializing this is because the App.exe.config is read-only, so any changes to the settings don't persist. This is where the serialization comes into play. If I can get it to output into the xml file above, I'm golden.

The problem now, is getting it into the correct format. I see two problems with this.

One, the class contains all static members so when I call XmlSerializer.Serialize( <stream>, <object to serialize> ) I don't have an object to use.

Problem two, for each member variable how to output the xml <add key="isConstant" value="true" />, etc.

This is about as far as I get . . .

[XmlRoot("appSettings")]
class Settings
{
public static bool isConstant;
public static bool doReports;
}

Which as you can see, isn't far. Smile | :) I don't know how to have the <add> element for each member variable. It won't let me add [XmlElement("add")] before each member variable. (it complains about using the same element name) And I don't know how to get the correct attributes into the xml.

Any ideas? Or better ways of doing this?

Thanks.
GeneralKeyword.... Pin
Steve McLenithan28-Jun-03 17:41
Steve McLenithan28-Jun-03 17:41 
GeneralRe: Keyword.... Pin
Bo Hunter28-Jun-03 18:19
Bo Hunter28-Jun-03 18:19 
GeneralRe: Keyword.... Pin
Steve McLenithan28-Jun-03 18:36
Steve McLenithan28-Jun-03 18:36 
QuestionHow Do I: Write an Addin for IE in C# Pin
Rahul Singh28-Jun-03 13:48
Rahul Singh28-Jun-03 13:48 
AnswerRe: How Do I: Write an Addin for IE in C# Pin
Mazdak29-Jun-03 4:32
Mazdak29-Jun-03 4:32 
AnswerRe: How Do I: Write an Addin for IE in C# Pin
J. Dunlap29-Jun-03 8:32
J. Dunlap29-Jun-03 8:32 
GeneralRe: How Do I: Write an Addin for IE in C# Pin
leppie29-Jun-03 9:35
leppie29-Jun-03 9:35 
GeneralRe: How Do I: Write an Addin for IE in C# Pin
Rocky Moore30-Jun-03 0:42
Rocky Moore30-Jun-03 0:42 
GeneralWeb Service Pin
puppiesLover28-Jun-03 8:57
puppiesLover28-Jun-03 8:57 
GeneralRe: Web Service Pin
Mazdak28-Jun-03 9:27
Mazdak28-Jun-03 9:27 
GeneralSystem.Web.Services not available Pin
puppiesLover28-Jun-03 8:36
puppiesLover28-Jun-03 8:36 
GeneralRe: System.Web.Services not available Pin
Mazdak28-Jun-03 9:30
Mazdak28-Jun-03 9:30 
Generalunable to use mouse in combobox Pin
monrobot1328-Jun-03 5:24
monrobot1328-Jun-03 5:24 
GeneralRe: unable to use mouse in combobox Pin
leppie28-Jun-03 5:57
leppie28-Jun-03 5:57 
GeneralRe: unable to use mouse in combobox Pin
James T. Johnson28-Jun-03 7:01
James T. Johnson28-Jun-03 7:01 
GeneralRe: unable to use mouse in combobox Pin
monrobot1328-Jun-03 10:37
monrobot1328-Jun-03 10:37 
GeneralRe: unable to use mouse in combobox Pin
James T. Johnson29-Jun-03 1:08
James T. Johnson29-Jun-03 1:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.