Click here to Skip to main content
15,893,508 members
Home / Discussions / C#
   

C#

 
AnswerMessage Closed Pin
11-Sep-09 4:34
stancrm11-Sep-09 4:34 
GeneralRe: Anybody know the command to insert an image into a byte [] array? Pin
Member 1035577327-Jan-14 11:45
Member 1035577327-Jan-14 11:45 
Questionmake exe file Pin
ali_reza_zareian11-Sep-09 4:00
ali_reza_zareian11-Sep-09 4:00 
AnswerRe: make exe file Pin
Pete O'Hanlon11-Sep-09 4:13
mvePete O'Hanlon11-Sep-09 4:13 
NewsRe: make exe file Pin
ali_reza_zareian11-Sep-09 9:13
ali_reza_zareian11-Sep-09 9:13 
AnswerRe: make exe file Pin
stancrm11-Sep-09 4:13
stancrm11-Sep-09 4:13 
AnswerRe: make exe file Pin
PIEBALDconsult11-Sep-09 4:15
mvePIEBALDconsult11-Sep-09 4:15 
QuestionSetting private fields of nested classes using reflection Pin
BRShroyer11-Sep-09 3:39
BRShroyer11-Sep-09 3:39 
I'm trying to make a group settings classes that read XML files and set the appropriate fields in those classes. Here are the classes I have:

SettingsBase
System1Settings : SettingsBase
System2Settings : SettingsBase
...

I also have some sub classes that grouped common settings together for easier coding.
class System1Macros
{
  string macro1;
  string macro2;
  ...
}
class System1Registers
{
  string register1;
  string register2;
  ...
}

Inside each system class, I have some fields that inherit from those classes. For example, inside System1Settings:
System1Macros macros;
System1Registers registers;

My settings.xml files have the format:
<?xml version="1.0" encoding="utf-8" ?>
<System1Settings>
  <Setting name="SomeSetting1">Major1</Setting>
  <Setting name="SomeSetting2">Major2</Setting>
  <Setting name="SomeSetting3">Major3</Setting>
  ...
  <Macros>
    <Setting name="Macro1">1</Setting>
    <Setting name="Macro2">10</Setting>
    ...
  </Macros>
  <Registers>
    <Setting name="Register1">1</Setting>
    <Setting name="Register2">2</Setting>
    ...
  </Registers>
</System1Settings>

What I want to do is read in the System1Settings.xml file and set all of fields in System1Settings (the values in the first level of the xml file) and the fields in the specialized classes to the other levels of the xml file. So:
System1Settings.setting1 = SomeSetting1
System1Settings.setting2 = SomeSetting2
...
System1Settings.macros.macro1 = Macro1
System1Settings.macros.macro2 = Macro2
...
System1Settings.registers.register1 = Register1
System1Settings.registers.register2 = Register2
...

Right now I'm trying to use reflection in the SettingsBase (thinking I could write this routine once for all child classes and not have to rewrite each time I make a new settings class), but I'm not sure how to drill down through the fields in the SystemSettings classes to know which fields in the child classes are subclasses that need to be set. I thought there was a way to serialize/deserialize the XML, but I don't know that I can use the class structure I have.

Any insights, critiques, or nudge/shove/push/kick in the right direction would be appreciated.

Thank you,

Brad

Deja Moo - When you feel like you've heard the same bull before.

AnswerRe: Setting private fields of nested classes using reflection Pin
PIEBALDconsult11-Sep-09 4:26
mvePIEBALDconsult11-Sep-09 4:26 
QuestionRemoving shim and placing VSTO. Pin
SRKSHOME11-Sep-09 3:38
SRKSHOME11-Sep-09 3:38 
QuestionFTPS SSL/TLS Issue on Some Computers Pin
SimpleData11-Sep-09 2:28
SimpleData11-Sep-09 2:28 
QuestionC# Background Worker losing variable value in Progress Pin
Wheels01211-Sep-09 2:15
Wheels01211-Sep-09 2:15 
AnswerRe: C# Background Worker losing variable value in Progress Pin
DaveyM6911-Sep-09 2:56
professionalDaveyM6911-Sep-09 2:56 
GeneralRe: C# Background Worker losing variable value in Progress Pin
Wheels01211-Sep-09 3:48
Wheels01211-Sep-09 3:48 
GeneralRe: C# Background Worker losing variable value in Progress Pin
DaveyM6911-Sep-09 4:14
professionalDaveyM6911-Sep-09 4:14 
AnswerRe: C# Background Worker losing variable value in Progress Pin
Alan N11-Sep-09 2:56
Alan N11-Sep-09 2:56 
AnswerRe: C# Background Worker losing variable value in Progress Pin
DaveyM6911-Sep-09 3:10
professionalDaveyM6911-Sep-09 3:10 
QuestionDBNull error Pin
kanchoette11-Sep-09 1:38
kanchoette11-Sep-09 1:38 
AnswerRe: DBNull error Pin
monstale11-Sep-09 2:22
monstale11-Sep-09 2:22 
AnswerRe: DBNull error Pin
J4amieC11-Sep-09 2:22
J4amieC11-Sep-09 2:22 
AnswerRe: DBNull error Pin
PIEBALDconsult11-Sep-09 4:28
mvePIEBALDconsult11-Sep-09 4:28 
QuestionHow do I read in a h246 .mp4 file and change some hex in the file and then save the file back out? Pin
thestonefox11-Sep-09 1:05
thestonefox11-Sep-09 1:05 
AnswerRe: How do I read in a h246 .mp4 file and change some hex in the file and then save the file back out? Pin
stancrm11-Sep-09 1:22
stancrm11-Sep-09 1:22 
QuestionC# Excel. Find a specific cell and write in string data into the cell to the right of the found cell. [modified] Pin
gjx_junxian198911-Sep-09 0:16
gjx_junxian198911-Sep-09 0:16 
QuestionWMI Pin
moein.serpico10-Sep-09 23:57
moein.serpico10-Sep-09 23:57 

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.