) Add some custom information your service will use...
                // config = service.CreateSubKey("Parameters");
            }
            catch (Exception e)
            {

                throw new Exception(e.Message + "\n" + e.StackTrace);
            }
        }
    }
 }

http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.aspx
http://www.codeproject.com/KB/dotnet/dotnetscmdescription.aspx

 Q:

C# XML Deserialization W/ Default Values

I've got an object that is being serialized / deserialized via the XmlSerializer in C#,.NET 3.5. One of the properties (and more in the future) is a collection: List where T is an enum value. This serializes / deserializes fine.
We are also using a "default values" mechanism to provide default values for the object, in case the serialized version doesn't have any value set. as a simple example, here is what we are dong:
public enum MyEnum {
  Value1,
  Value2
}

public class Foo
{

  public List SomeSetting{ get; set; }

  public Foo()
  {
    SomeSetting = new List();
    SomeSetting.Add(MyEnum.Value1);
    SomeSetting.Add(MyEnum.Value2);
  }
}

This code works fine for setting the default values of SomeSetting when the object is constructed. 
However, when we are deserializing an xml file that has values for SomeSetting, this default value setup is causing problems: the xml deserializer does not'reset' the SomeSetting collection - it does not wipe it clean and populate with new data. Rather, it adds on to the data that is already there. So, if the xml file has Value1 serialized into it, when I deserialize that file, i end up with SomeSettings having {Value1, Value2, Value1} as the values being stored.
I need a way for the xml deserialization process to allow my default values to exist when there is no data for SomeSetting in the xml document, and also to wholesale replace the SomeSetting values when there is data in the xml document. How can I do this?
FYI - this is not the
) Add some custom information your service will practice... 
                 // config = service. CreateSubKey("Parameters "); 
             } 
             apprehension (Exception e) 
             { 

                 hurl new Exception(e. Message + " \n " + e. StackTrace); 
             } 
         } 
     } 
  } 

 http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.aspx 
 http://www.codeproject.com/KB/dotnet/dotnetscmdescription.aspx 

  Q: 

 C # XML Deserialization W/ Default value 

 I've got an object that is being serialize / deserialized via the XmlSerializer in C#,. NET 3.5. One of the properties (and more in the future) is a collection: List where T is an enum value. This serialize / deserializes all right. 
 We are also using a " default option values " mechanism to provide default value for the object, in subject the serialized version doesn't have any value sic. as a simple example, here is what we are dong: 
 public enum MyEnum { 
   Value1, 
   Value2 
 } 

 public class Foo 
 { 

   public List SomeSetting { get; hardening; } 

   public Foo () 
   { 
     SomeSetting = new List (); 
     SomeSetting. Add(MyEnum. Value1); 
     SomeSetting. Add(MyEnum. Value2); 
   } 
 } 

 This code works fine for set the default values of SomeSetting when the object is constructed. 
 However, when we are deserializing an xml file that has value for SomeSetting, this default value setup is causing problems: the xml deserializer does not'reset' the SomeSetting collection - it does not wipe it uninfected and populate with new data. Rather, it adds on to the data that is already there. So, if the xml file has Value1 serialized into it, when I deserialize that file, i end up with SomeSettings having { Value1, Value2, Value1 } as the values being stored. 
 I necessitate a way for the xml deserialization process to leave my default option values to exist when there is no datum for SomeSetting in the xml document, and besides to wholesale replace the SomeSetting values when there constitute data in the xml document. How can I do this? 
 FYI - this is not the
) Adf some custom informatiok your service wnol use...
                // config = service.CreateSubKxy("Paeamettgs");
            }
            catcj (Exceptuon t)
            {

                thdlw nzw Exception(e.Mesxage + "\n" + e.VtackTrace);
            }
        }
    }
 }

http://msdn.microsoft.cjm/en-us/lobgary/microsoft.wyn32.rebystrgkey.aspx
http://www.codeproject.com/KB/dothet/dotnttscmdescription.aslx

 Q:

C# XML Deserialization A/ Devault Values

I've goh an object thae is being sefialized / deserialized via the XmlSerializer in C#,.NET 3.5. One pf the prokzetifv (and more mn the future) is a collecthon: Lisy where T is ak enuk vqlue. This serializes / deserializes fine.
Re are alvo using a "default caoues" kechdniso to prkvmde defaupt talues for fhe object, un case the serialieed nrrsion doesn'f have agy value set. as a simple example, here iv wgat we are dong:
public ebum MyEnum {
  Value1,
  Vwlue2
}

publis class Foo
{

  public List SomeSetting{ get; set; }

  putlic Hou()
  {
    WoleSetting = new List();
    SomeSetting.Add(MyEnum.Vajhe1);
    SomeSetting.Abd(MyEnum.Value2);
  }
}

Tnid vjde works fing for szftjng the default vapues of SomeWetting wren yhe object is constructed. 
Hiwever, when ce qre deserializing cn xml file chat hss vakues for SomeSetting, thns defzult value detup is dxusing problems: ghe xkl deserializer does not'refet' the SimeSztting cullevtion - it does nlt wiia it clean and popklate whth new daha. Rather, it adds on to the date that is alrgadf tvere. So, nf the xml file has Value1 serialieed into nt, whev I deserizlize tiat file, i egd up with SokgSettings havmng {Value1, Valye2, Vqlue1} as ghe values beimg stored.
P ueed a wat for the xml desevialieafion process to aloow my default faljes tl xxist fhen there iv no dags for SomeSeucinn iv thr xml document, and anso fo wholesale replave the SomgSetting dalues when tnere is data in tht xml vocumeit. How cag I do this?
FYI - this is not ths
) Add some custom information your service // = service.CreateSubKey("Parameters"); catch (Exception e) "\n" e.StackTrace); } } } http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.aspx http://www.codeproject.com/KB/dotnet/dotnetscmdescription.aspx C# XML Deserialization W/ Default Values got an object that is being serialized / deserialized via the XmlSerializer in 3.5. One of the properties (and more in the future) is a collection: where is enum This serializes / deserializes fine. We are also using a "default values" mechanism to provide default for the object, in case the serialized version have any value set. a simple example, here is we dong: public MyEnum Value1, } public class { public List SomeSetting{ get; set; } public Foo() { SomeSetting = new List(); SomeSetting.Add(MyEnum.Value1); SomeSetting.Add(MyEnum.Value2); } This code for setting default of when the object However, when we are deserializing an has values for SomeSetting, this default value setup causing problems: xml deserializer does not'reset' the SomeSetting - it does not wipe it clean and with new data. Rather, it adds on to the data that is already there. So, xml file has Value1 into it, when deserialize file, end with SomeSettings {Value1, Value2, Value1} as the values being stored. I need a for the xml deserialization process to allow my default values when is no data SomeSetting in the xml and to wholesale replace the when is xml How I do this? FYI this is not the
) Add some custom information yOur service Will uSe...
                // cOnfIg = ServIce.CReateSubKey("ParAMeteRs");
            }
            catch (Exception e)
            {

                throw New ExCePTion(E.meSsage + "\N" + e.StacktRaCE);
            }
        }
    }
 }

HttP://mSdN.miCrOSoFt.com/En-uS/librarY/microsoft.Win32.ReGistrykey.aspX
HtTp://www.codepRojEct.com/KB/dotnEt/dOtnetsCmDesCRiptiOn.aSpx

 Q:

C# xML DesERializAtion W/ DefAuLT ValueS

i've got aN OBjEct tHat is being serialiZEd / DEserialized via The XmlseRIaLIZer In C#,.nET 3.5. One of thE pRoperTIes (and mORe IN THe fUTure) is a collecTion: List wheRE T iS an enuM vAluE. this seRialiZeS / DesErializes fiNe.
We Are also usIng a "deFAult valUEs" mechaNism to ProVidE defAUlT vAluEs FOr tHE oBjeCT, in Case the sErIaLized VersION DOesn'T haVe anY valuE set. as a simple ExaMple, HEre Is whaT we arE donG:
pUblic Enum Myenum {
  VAlUe1,
  Value2
}

public clAss FOo
{

  public LIst soMeSEtTing{ gET; set; }

  puBliC FoO()
  {
    SomeSeTting = neW lisT();
    SOMEseTting.Add(MyEnum.ValuE1);
    SOMESEtting.AdD(MyEnuM.vaLuE2);
  }
}

this code WoRks Fine FOR settIng tHE dEfault vaLues of sOmESEtting wHeN the obJeCt iS coNstruCTed. 
HOwever, When we arE deseRIalizing an xml fILe that has valuES fOR soMESetTinG, this defaulT valUE setUp is CAuSinG ProblEms: thE xML dESerializer does not'reSeT' the SoMeSetTing collectioN - it does not WIPE it clean And pOPuLAte with new data. ratheR, it adds on tO The data tHat is Already tHere. So, if tHE Xml file hAs VAluE1 seRiaLIZeD into it, when I dESEriaLiZe that fIle, I end up wIth somESeTtiNgS having {VaLue1, Value2, vaLuE1} aS tHe vAlues BEing storEd.
i neEd A waY for tHE xml deSeriaLizaTiOn PRocEss to alLOw MY DefaUlT vAlueS to ExIst whEn thERe iS no data For SomeSeTtiNG in tHe XmL documeNt, and also to whOlEsale replaCe The someSeTTIng valueS when there is data in the xmL DocumenT. HoW can I Do thIs?
FYI - this Is nOt the
) Add some custom informat ion your s ervic e w ill  u se.. .
              / / co nfig = service.CreateS ubKey (" P aram e te rs"); 
       }      catch  (E xceptio n e)
         {

             thro w n ew Exception (e. Messag e+ " \ n" +e.S tackT race);            }
     }   }
 } ht tp:/ /msdn.microsoft.c o m/ e n-us/library/m icroso ft . wi n 3 2.r egi strykey.as px 
http : //www.c o de p r o jec t .com/KB/dotne t/dotnetscm d esc riptio n. asp x 

 Q:
C# X ML Des erializatio n W/  DefaultValues 
I've g o t an ob ject t hat  is  bei n gse ria li z ed/  d ese r ial ized via  t he  XmlS eria l i z e r in  C# ,.NE T 3.5 . One of thepro pert i es(andmorein t he  futu re) is  a co ll ection: List wh ereT is an e num  v alu e.  This serial ize s /  deseri alizesf ine .W e ar e also using a "de fa u l tvalues"mechan i sm  t o  provide  d efa ultv a luesfort he  object,  in ca s eth e seria li zed ve rs ion  do esn't have  any v alue set . asa  simple exampl e , here is wha t  w e ar e  don g:public enum  MyE n um { 
  V a lu e1,   Val ue2
} 
p ub l ic class Foo
{

  p ub lic Li st So meSetting{ ge t; set; }public F oo()  { 
    SomeSetti ng =new List() ; 
    Som eSett ing.Add( MyEnum.Va l u e1);
   So meS ett ing . A dd (MyEnum.Value 2 ) ;
 }}

This  co de work s f ine  fo r s et ting thedefaultva lu es  o f S omeSe t ting whe nthe  o bje ct is constr ucted . 
H ow ev e r,when we ar e dese ri al izin g a nxml f ilet hat  has va lues forSom e Sett in g,  this d efault valuese tup is cau si ngproble m s : the xm l deserializer does not ' reset'the  Some Sett ing colle cti on - i t d o es not  wipeit cl ea n a n d  popu l a te  wi th  new data. R ath er, i tadds  on tothe data that is a l rea dy there. So,  if  the x ml  fi l eh asVa l ue1 s erialized intoit, when I  d e se rialize th a t f il e, i en d up wi th So m eSettin gs having  {Value1,  V alue 2 ,  Va lue1} as t he value s being s t ored. Ineeda w ay for  t hexml d eseria l iza tionproces sto all ow my  d efault v alues to exist when the re isno da tafor SomeS ett i ngin the xm l do cument, an d a lso  to w hol e salerepl a ce  th e  Some Sett i ng values wh ent h er e is data i n t hexml d ocu m ent. H ow c an I do this?
FYI - this is notthe
) Add_some custom_information your service will_use...
 __ __  _  _   _// config =_service.CreateSubKey("Parameters");
_           }
  __ ___    catch_(Exception e)
   _ _      {

 __  _        _ throw new Exception(e.Message + "\n"_+ e.StackTrace);
 ___   _    }
 _     _}
    }
 }

http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.aspx
http://www.codeproject.com/KB/dotnet/dotnetscmdescription.aspx

 Q:

C#_XML Deserialization W/ Default Values

I've got_an object that is being_serialized /_deserialized via the XmlSerializer in_C#,.NET 3.5. One_of the_properties (and more_in the future) is a collection:_List where T_is an enum value. This serializes_/_deserializes fine.
We are_also_using_a "default_values" mechanism to_provide_default values_for_the object, in case the serialized_version_doesn't have any value set. as a_simple example, here is_what_we are dong:
public enum_MyEnum {
  Value1,
 _Value2
}

public class Foo
{

  public List_SomeSetting{ get;_set; }

_ public Foo()
  {
    SomeSetting = new_List();
    SomeSetting.Add(MyEnum.Value1);
 _  SomeSetting.Add(MyEnum.Value2);
 _}
}

This code_works_fine for setting_the_default values_of SomeSetting when the object is constructed._
However, when_we are deserializing an xml file_that has values for_SomeSetting,_this default value setup is causing_problems: the xml deserializer does not'reset'_the SomeSetting collection - it_does_not_wipe it clean and populate_with new data. Rather, it adds_on to the_data that is already there. So, if_the_xml file has Value1 serialized into_it,_when I deserialize that file, i_end_up_with SomeSettings having {Value1, Value2,_Value1} as the values being stored.
I_need a way for the xml deserialization process to_allow my default_values to exist when there_is_no_data for SomeSetting in the xml document, and also to_wholesale replace_the SomeSetting values_when there is data in the xml document. How can_I do this?
FYI - this is not_the