XsdDataContractImporter Constructor (CodeCompileUnit)

XsdDataContractImporter Constructor (CodeCompileUnit)


Initializes a new instance of the XsdDataContractImporter class with the CodeCompileUnit that will be used to generate CLR code.

Namespace:   System.Runtime.Serialization
Assembly:  System.Runtime.Serialization (in System.Runtime.Serialization.dll)

public XsdDataContractImporter(
	CodeCompileUnit codeCompileUnit


Type: System.CodeDom.CodeCompileUnit

The CodeCompileUnit that will be used to store the code.

Use this constructor to add more code into a CodeCompileUnit that has already been generated.

Legacy Code Example

The following example creates an XmlSchemaSet and calls the Import method to create a CodeCompileUnit. The CodeCompileUnit is then used to create both Visual C# and Visual Basic code files.

public void SaveMyFile()
   // Create a SaveFileDialog to request a path and file name to save to.
   SaveFileDialog saveFile1 = new SaveFileDialog();

   // Initialize the SaveFileDialog to specify the RTF extension for the file.
   saveFile1.DefaultExt = "*.rtf";
   saveFile1.Filter = "RTF Files|*.rtf";

   // Determine if the user selected a file name from the saveFileDialog.
   if(saveFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
      saveFile1.FileName.Length > 0) 
      // Save the contents of the RichTextBox into the file.
      richTextBox1.SaveFile(saveFile1.FileName, RichTextBoxStreamType.PlainText);

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft