code_junkie

XmlSerializer changes in .NET 3.5 SP1

Nov 10th, 2011
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. [XmlRoot("foo")]
  2. public class Foo
  3. {
  4. static void Main()
  5. {
  6. XmlSerializer serializer = new XmlSerializer(typeof(Foo));
  7.  
  8. string xml = @"<foo name='ack' />";
  9. using (StringReader sr = new StringReader(xml))
  10. {
  11. Foo foo = serializer.Deserialize(sr) as Foo;
  12. }
  13. }
  14.  
  15. [XmlAttribute("name")]
  16. public string Name { get; set; }
  17.  
  18. public Foo Bar { get; private set; }
  19. }
  20.  
  21. <system.diagnostics>
  22. <switches>
  23. <add name="XmlSerialization.Compilation" value="1" />
  24. </switches>
  25. </system.diagnostics>
  26. <system.xml.serialization>
  27. <xmlSerializer tempFilesLocation="c:\foo"/>
  28. </system.xml.serialization>
  29.  
  30. <system.xml.serialization>
  31. <xmlSerializer tempFilesLocation="c:\foo"/>
  32. </system.xml.serialization>
Add Comment
Please, Sign In to add comment