本文整理汇总了C#中IndentedTextWriter.Close方法的典型用法代码示例。如果您正苦于以下问题:C# IndentedTextWriter.Close方法的具体用法?C# IndentedTextWriter.Close怎么用?C# IndentedTextWriter.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndentedTextWriter
的用法示例。
在下文中一共展示了IndentedTextWriter.Close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateAssembly
private static Assembly GenerateAssembly(string asmxFile)
{
string strWsdl = WsdlFromUrl(GetApplicationPath() + "/" + asmxFile + "?wsdl");
// Xml text reader
StringReader wsdlStringReader = new StringReader(strWsdl);
XmlTextReader tr = new XmlTextReader(wsdlStringReader);
ServiceDescription sd = ServiceDescription.Read(tr);
tr.Close();
// WSDL service description importer
CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
CodeNamespace codeNamespaceFluorine = new CodeNamespace("FluorineFx");
codeCompileUnit.Namespaces.Add(codeNamespaceFluorine);
CodeNamespace codeNamespace = new CodeNamespace(FluorineConfiguration.Instance.WsdlProxyNamespace);
codeCompileUnit.Namespaces.Add(codeNamespace);
#if (NET_1_1)
ServiceDescriptionImporter sdi = new ServiceDescriptionImporter();
sdi.AddServiceDescription(sd, null, null);
sdi.ProtocolName = "Soap";
sdi.Import(codeNamespace, codeCompileUnit);
CSharpCodeProvider provider = new CSharpCodeProvider();
#else
// Create a WSDL collection.
DiscoveryClientDocumentCollection wsdlCollection = new DiscoveryClientDocumentCollection();
wsdlCollection.Add(asmxFile, sd);
// Create a web refererence using the WSDL collection.
WebReference reference = new WebReference(wsdlCollection, codeNamespace);
reference.ProtocolName = "Soap12";
// Create a web reference collection.
WebReferenceCollection references = new WebReferenceCollection();
references.Add(reference);
WebReferenceOptions options = new WebReferenceOptions();
options.Style = ServiceDescriptionImportStyle.Client;
options.CodeGenerationOptions = CodeGenerationOptions.None;
options.SchemaImporterExtensions.Add(typeof(DataTableSchemaImporterExtension).AssemblyQualifiedName);
CSharpCodeProvider provider = new CSharpCodeProvider();
ServiceDescriptionImporter.GenerateWebReferences(references, provider, codeCompileUnit, options);
// Compile a proxy client
//provider.GenerateCodeFromCompileUnit(codeCompileUnit, Console.Out, new CodeGeneratorOptions());
#endif
//http://support.microsoft.com/default.aspx?scid=kb;en-us;326790
//http://pluralsight.com/wiki/default.aspx/Craig.RebuildingWsdlExe
if (!FluorineConfiguration.Instance.WsdlGenerateProxyClasses)
{
//Strip any code that isn't the proxy class itself.
foreach (CodeNamespace cns in codeCompileUnit.Namespaces)
{
// Remove anything that isn't the proxy itself
ArrayList typesToRemove = new ArrayList();
foreach (CodeTypeDeclaration codeType in cns.Types)
{
bool webDerived = false;
foreach (CodeTypeReference baseType in codeType.BaseTypes)
{
if (baseType.BaseType == "System.Web.Services.Protocols.SoapHttpClientProtocol")
{
webDerived = true;
break;
}
}
if (!webDerived)
typesToRemove.Add(codeType);
else
{
CodeAttributeDeclaration codeAttributeDeclaration = new CodeAttributeDeclaration(typeof(FluorineFx.RemotingServiceAttribute).FullName);
codeType.CustomAttributes.Add(codeAttributeDeclaration);
foreach (CodeTypeMember member in codeType.Members)
{
CodeConstructor ctor = member as CodeConstructor;
if (ctor != null)
{
// We got a constructor
// Add CookieContainer code
// this.CookieContainer = new System.Net.CookieContainer(); //Session Cookie
CodeSnippetStatement statement = new CodeSnippetStatement("this.CookieContainer = new System.Net.CookieContainer(); //Session Cookie");
ctor.Statements.Add(statement);
}
}
}
}
foreach (CodeTypeDeclaration codeType in typesToRemove)
{
codeNamespace.Types.Remove(codeType);
}
}
}
else
{
foreach (CodeNamespace cns in codeCompileUnit.Namespaces)
{
foreach (CodeTypeDeclaration codeType in cns.Types)
{
bool webDerived = false;
//.........这里部分代码省略.........
示例2: CompileLocations
static void CompileLocations (string outputFile)
{
CodeCompileUnit unit = new CodeCompileUnit ();
CodeNamespace ns = new CodeNamespace ("Desklet.Weather");
unit.Namespaces.Add (ns);
ns.Imports.Add (new CodeNamespaceImport ("System"));
ns.Imports.Add (new CodeNamespaceImport ("System.Collections.Generic"));
MainClass = new CodeTypeDeclaration ("Locations");
MainClass.TypeAttributes = TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public;
MainClass.IsPartial = true;
ns.Types.Add (MainClass);
CodeMemberMethod buildData = new CodeMemberMethod ();
buildData.Name = "BuildData";
GenerateBuildData (buildData);
MainClass.Members.Add (buildData);
CodeDomProvider provider = new CSharpCodeProvider ();
ICodeGenerator gen = provider.CreateGenerator ();
TextWriter tw = new IndentedTextWriter (new StreamWriter (outputFile, false), "\t");
gen.GenerateCodeFromCompileUnit (unit, tw, new CodeGeneratorOptions ());
tw.Close ();
}