当前位置: 首页>>代码示例>>C#>>正文


C# System.IO.StringWriter.Dispose方法代码示例

本文整理汇总了C#中System.IO.StringWriter.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.StringWriter.Dispose方法的具体用法?C# System.IO.StringWriter.Dispose怎么用?C# System.IO.StringWriter.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.StringWriter的用法示例。


在下文中一共展示了System.IO.StringWriter.Dispose方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToString

 public override string ToString()
 {
     var sw = new System.IO.StringWriter();
     using (XmlTextWriter writer = new XmlTextWriter(sw))
     {
         writer.Formatting = Formatting.Indented;
         writer.Indentation = 4;
         writer.WriteStartElement("Step");
         writer.WriteElementString("Enable", Enable.ToString());
         writer.WriteElementString("Comment", Comment);
         writer.WriteElementString("OnFailureLable", OnFailureLabel);
         writer.WriteRaw(Action.ToString());
         writer.WriteEndElement();
     }
     string retval = sw.ToString();
     sw.Close();
     sw.Dispose();
     return retval;
 }
开发者ID:roikoazulay,项目名称:AutoLaunch,代码行数:19,代码来源:StepEntity.cs

示例2: ToString

 public override string ToString()
 {
     var sw = new System.IO.StringWriter();
     using (var writer = new XmlTextWriter(sw))
     {
         writer.Formatting = Formatting.Indented;
         writer.Indentation = 4;
         writer.WriteStartElement("Action");
         writer.WriteElementString("ID", ((int)TypeId).ToString());
         writer.WriteElementString("Name", Name);
         writer.WriteStartElement("Details");
         foreach (string data in Details)
             writer.WriteElementString("Detail", data);
         writer.WriteEndElement();
         writer.WriteEndElement();
     }
     string retval = sw.ToString();
     sw.Close();
     sw.Dispose();
     return retval;
 }
开发者ID:roikoazulay,项目名称:AutoLaunch,代码行数:21,代码来源:ActionBase.cs

示例3: ToString

 public override string ToString()
 {
     var sw = new System.IO.StringWriter();
     using (XmlTextWriter writer = new XmlTextWriter(sw))
     {
         writer.Formatting = Formatting.Indented;
         writer.Indentation = 4;
         writer.WriteStartDocument();
         writer.WriteStartElement("Test");
         //writer.WriteElementString("Enable", Enable.ToString());
         writer.WriteElementString("Description", Description);
         writer.WriteStartElement("Scripts");
         foreach (TestEntity entity in Entities)
             writer.WriteRaw(entity.ToString());
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.WriteEndDocument();
     }
     string retval = sw.ToString().Replace("utf-16", "utf-8"); ;
     sw.Close();
     sw.Dispose();
     return retval;
 }
开发者ID:roikoazulay,项目名称:AutoLaunch,代码行数:23,代码来源:TestObj.cs

示例4: TransformXml

        public static string TransformXml(System.Xml.XmlDocument Document, string XslPath)
        {
            XslCompiledTransform xTrans = null;

            #region Do the transform

            try
            {
                bool debugmode = false;
            #if DEBUG
                debugmode = true;
            #endif
                xTrans = new XslCompiledTransform(debugmode);
                xTrans.Load(XslPath);
            }
            catch (Exception ex)
            {
                throw new Exception("Could not load XSL Transform", ex);
            }

            string results = "";

            try
            {
                System.IO.StringReader SR = new System.IO.StringReader(Document.OuterXml);
                System.Xml.XmlReaderSettings xReadSettings = new System.Xml.XmlReaderSettings();
                xReadSettings.CloseInput = true;
                xReadSettings.ConformanceLevel = System.Xml.ConformanceLevel.Fragment;
                xReadSettings.IgnoreComments = true;
                xReadSettings.IgnoreWhitespace = true;
                System.Xml.XmlReader xReader = System.Xml.XmlReader.Create(SR, xReadSettings);

                StringBuilder SB = new StringBuilder();
                System.IO.StringWriter SW = new System.IO.StringWriter(SB);
                System.Xml.XmlWriterSettings xWriteSettings = new System.Xml.XmlWriterSettings();
                xWriteSettings.CloseOutput = true;
                xWriteSettings.Indent = false;
                xWriteSettings.NewLineOnAttributes = false;
                xWriteSettings.ConformanceLevel = System.Xml.ConformanceLevel.Fragment;

                System.Xml.XmlWriter xWriter = System.Xml.XmlWriter.Create(SW, xWriteSettings);

                xTrans.Transform(xReader, xWriter);

                results = SB.ToString();

                xWriter.Close();
                xReader.Close();

                SR.Dispose();
                SR = null;
                SW.Dispose();
                SW = null;
            }
            catch (Exception ex)
            {
                throw new Exception("Could not transform Design XML.", ex);
            }

            #endregion

            return results;
        }
开发者ID:RiverTaig,项目名称:CU_ATE,代码行数:63,代码来源:LabellingUtility.cs

示例5: GetXml

 public string GetXml() {
     StringBuilder xml = null;
     System.IO.StringWriter sw = null;
     try {
         var s = new System.Xml.Serialization.XmlSerializer(typeof(CalculationOptionsDPSWarr));
         xml = new StringBuilder();
         sw = new System.IO.StringWriter(xml);
         s.Serialize(sw, this);
     } finally { sw.Dispose(); }
     return xml.ToString();
 }
开发者ID:LucasPeacecraft,项目名称:rawr,代码行数:11,代码来源:CalculationOptionsDPSWarr.cs

示例6: ConvertXamlToHtml

        /// <summary>
        /// Converts an flow document to html string.
        /// </summary>
        /// <param name="flowDocument">Flow document.</param>
        /// <param name="conversionResult">Conversion result to store error and warning messages. Can be null.</param>
        /// <returns>
        /// Well-formed xml string representing html equivalent for the input flow document.
        /// </returns>
        public static string ConvertXamlToHtml(FlowDocument flowDocument, ValidationResult conversionResult)
        {
            StringBuilder htmlStringBuilder = new StringBuilder();
            System.IO.StringWriter stringWriter = null;
            try
            {
                stringWriter = new System.IO.StringWriter(htmlStringBuilder);
                using (XmlTextWriter htmlWriter = new XmlTextWriter(stringWriter))
                {
                    try
                    {
                        foreach (Block block in flowDocument.Blocks)
                        {
                            AddBlock(block, htmlWriter, conversionResult);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (conversionResult != null)
                            conversionResult.AddMessage(new ConversionMessage(ModelValidationViolationType.Error, "Conversion failed: " + ex.Message));
                    }
                    finally
                    {
                        stringWriter = null;
                    }
                }
            }
            finally
            {
                if (stringWriter != null)
                    stringWriter.Dispose();
            }

            string htmlString = htmlStringBuilder.ToString();
            return htmlString;
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:44,代码来源:XamlToHtmlConverter.cs

示例7: Evaluate

        public static CompileResult Evaluate(string code, bool autoCompleteComma = true)
        {
            if (autoCompleteComma && !code.EndsWith(";")) {
            code += ";";
            }

            var result = new CompileResult();
            result.code = code;

            // find commands at first and expand it if found.
            code = Commands.ConvertIntoCodeIfCommand(code);

            // if not match, eval the code using Mono.
            object ret = null;
            bool hasReturnValue = false;

            var originalOutput = Mono.CSharp.Evaluator.MessageOutput;
            var errorWriter = new System.IO.StringWriter();
            bool isPartial = false;
            Mono.CSharp.Evaluator.MessageOutput = errorWriter;
            try {
            isPartial = Mono.CSharp.Evaluator.Evaluate(code, out ret, out hasReturnValue) != null;
            } catch (System.Exception e) {
            errorWriter.Write(e.Message);
            }
            Mono.CSharp.Evaluator.MessageOutput = originalOutput;

            var error = errorWriter.ToString();
            if (!string.IsNullOrEmpty(error)) {
            error = error.Replace("{interactive}", "");
            var lastLineBreakPos = error.LastIndexOf('\n');
            if (lastLineBreakPos != -1) {
                error = error.Remove(lastLineBreakPos);
            }
            result.type  = CompileResult.Type.Error;
            result.error = error;
            return result;
            }
            errorWriter.Dispose();

            if (isPartial) {
            result.type = CompileResult.Type.Partial;
            return result;
            }

            result.type = CompileResult.Type.Success;
            result.value = (hasReturnValue && ret != null) ? ret : "null";
            return result;
        }
开发者ID:hecomi,项目名称:uREPL,代码行数:49,代码来源:Evaluator.cs


注:本文中的System.IO.StringWriter.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。