home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / InfoPath.en-us / InfLR.cab / FL_ReadClassDatafromanXMLFile_snippet_142736_ENU____.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Extensible Markup Language  |  2008-09-17  |  2KB  |  48 lines

  1. ∩╗┐<?xml version="1.0" encoding="UTF-8"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.   <CodeSnippet Format="1.0.0">
  4.     <Header>
  5.       <Title>Read Class Data from an XML File</Title>
  6.       <Author>Microsoft Corporation</Author>
  7.       <Description>Reads class data that was previously written to an XML file using the XmlSerializer class.</Description>
  8.       <Keywords>
  9.       </Keywords>
  10.       <Shortcut>xmlReadClass</Shortcut>
  11.     </Header>
  12.     <Snippet>
  13.       <References>
  14.         <Reference>
  15.           <Assembly>System.Xml.dll</Assembly>
  16.           <Version />
  17.           <Url />
  18.         </Reference>
  19.       </References>
  20.       <Imports>
  21.     <Import>
  22.       <Namespace>System.Xml.Serialization</Namespace>
  23.     </Import>
  24.     <Import>
  25.       <Namespace>System.IO</Namespace>
  26.     </Import>
  27.       </Imports>
  28.       <Declarations>
  29.         <Literal>
  30.           <ID>classType</ID>
  31.           <Type />
  32.           <ToolTip>Replace with the name of the class to be deserialized.</ToolTip>
  33.           <Default>TheClass</Default>
  34.         </Literal>
  35.         <Literal>
  36.           <ID>filename</ID>
  37.           <Type>String</Type>
  38.           <ToolTip>Replace with the name of the file that contains the serialized data.</ToolTip>
  39.           <Default>"ClassData.xml"</Default>
  40.         </Literal>
  41.       </Declarations>
  42.       <Code Language="VB" Kind="method body"><![CDATA[Dim reader As New XmlSerializer(GetType($ClassType$))
  43.         Dim file As New StreamReader($filename$)
  44.         Dim fileData As $ClassType$
  45.         fileData = CType(reader.Deserialize(file), $ClassType$)]]></Code>
  46.     </Snippet>
  47.   </CodeSnippet>
  48. </CodeSnippets>