本文整理匯總了C#中System.Runtime.Serialization.XsdDataContractImporter.XsdDataContractImporter構造函數的典型用法代碼示例。如果您正苦於以下問題:C# XsdDataContractImporter構造函數的具體用法?C# XsdDataContractImporter怎麽用?C# XsdDataContractImporter使用的例子?那麽, 這裏精選的構造函數代碼示例或許可以為您提供幫助。您也可以進一步了解該構造函數所在類System.Runtime.Serialization.XsdDataContractImporter
的用法示例。
在下文中一共展示了XsdDataContractImporter構造函數的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CompileCode
static void CompileCode(CodeCompileUnit ccu, string sourceName)
{
CodeDomProvider provider = null;
FileInfo sourceFile = new FileInfo(sourceName);
// Select the code provider based on the input file extension, either C# or Visual Basic.
if (sourceFile.Extension.ToUpper(CultureInfo.InvariantCulture) == ".CS")
{
provider = new Microsoft.CSharp.CSharpCodeProvider();
}
else if (sourceFile.Extension.ToUpper(CultureInfo.InvariantCulture) == ".VB")
{
provider = new Microsoft.VisualBasic.VBCodeProvider();
}
else
{
Console.WriteLine("Source file must have a .cs or .vb extension");
}
if (provider != null)
{
CodeGeneratorOptions options = new CodeGeneratorOptions();
// Set code formatting options to your preference.
options.BlankLinesBetweenMembers = true;
options.BracingStyle = "C";
StreamWriter sw = new StreamWriter(sourceName);
provider.GenerateCodeFromCompileUnit(ccu, sw, options);
sw.Close();
}
}