• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IO.StringWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetHtml

		public static string GetHtml (string url, HelpSource helpSource, out Node match)
		{
			string htmlContent = null;
			match = null;
			
			if (helpSource != null)
				htmlContent = AppDelegate.Root.RenderUrl (url, generator, out match, helpSource);
			if (htmlContent == null) {
				// the displayed url have a lower case type code (e.g. t: instead of T:) which confuse monodoc
				if (url.Length > 2 && url[1] == ':')
					url = char.ToUpperInvariant (url[0]) + url.Substring (1);
				// It may also be url encoded so decode it
				url = Uri.UnescapeDataString (url);
				htmlContent = AppDelegate.Root.RenderUrl (url, generator, out match, helpSource);
				if (htmlContent != null && match != null && match.Tree != null)
					helpSource = match.Tree.HelpSource;
			}
			if (htmlContent == null)
				return null;
			
			var html = new StringWriter ();
   			html.Write ("<html>\n<head><title>{0}</title>", url);
			
			if (helpSource != null) {
				if (HtmlGenerator.InlineCss != null)
                    html.Write (" <style type=\"text/css\">{0}</style>\n", HtmlGenerator.InlineCss);
				/*if (helpSource.InlineJavaScript != null)
                    html.Write ("<script type=\"text/JavaScript\">{0}</script>\n", helpSource.InlineJavaScript);*/
            }

            html.Write ("</head><body>");
            html.Write (htmlContent);
            html.Write ("</body></html>\n");
            return html.ToString ();
		}
开发者ID:Anomalous-Software,项目名称:monomac,代码行数:35,代码来源:DocTools.cs


示例2: ObjetoSerializado

 public static string ObjetoSerializado(Object Objeto)
 {
     System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(Objeto.GetType());
     System.IO.StringWriter textWriter = new System.IO.StringWriter();
     x.Serialize(textWriter, Objeto);
     return textWriter.ToString();
 }
开发者ID:pjeconde,项目名称:CedServicios,代码行数:7,代码来源:Funciones.cs


示例3: NormalSectionAndKey

        public void NormalSectionAndKey() {
            StringWriter writer = new StringWriter();
            writer.WriteLine("[Logging]");
            writer.WriteLine(" great logger =   log4net  ");
            writer.WriteLine("  [Pets] ; pets comment  ");
            IniReader reader = new IniReader(new StringReader(writer.ToString()));

            Assert.AreEqual(IniReadState.Initial, reader.ReadState);
            Assert.IsTrue(reader.Read());
            Assert.AreEqual(IniReadState.Interactive, reader.ReadState);
            Assert.AreEqual(IniType.Section, reader.Type);
            Assert.AreEqual("Logging", reader.Name);
            Assert.AreEqual("", reader.Value);
            Assert.IsNull(reader.Comment);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(IniType.Key, reader.Type);
            Assert.AreEqual("great logger", reader.Name);
            Assert.AreEqual("log4net", reader.Value);
            Assert.AreEqual(null, reader.Comment);

            Assert.IsTrue(reader.Read());
            Assert.AreEqual(IniType.Section, reader.Type);
            Assert.AreEqual("Pets", reader.Name);
            Assert.AreEqual("", reader.Value);
            Assert.IsNull(reader.Comment);
        }
开发者ID:debop,项目名称:NFramework,代码行数:27,代码来源:IniReaderTests.cs


示例4: InjectAssets

        protected string InjectAssets(string markup, Match match)
        {
            if (match == null)
            {
                return markup;
            }

            using (var writer = new StringWriter())
            {
                writer.Write(markup.Substring(0, match.Index));

                WriteLinks(writer, @"<link type=""text/css"" rel=""stylesheet"" href=""{0}"" />",
                           Compressor.CompressCss(GetSources(CssLinks)));
                WriteInlines(writer, "<style>", "</style>", CssInlines);
                WriteLinks(writer, @"<script type=""text/javascript"" src=""{0}""></script>",
                           Compressor.CompressJavascript(GetSources(JavascriptLinks)));
                WriteInlines(writer, @"<script type=""text/javascript"">", "</script>", JavascriptInlines);

                WriteInlines(
                    writer,
                    @"<script type=""text/javascript"">jQuery(document).ready(function () {",
                    "});</script>",
                    DomReadyInlines);

                writer.Write(markup.Substring(match.Index));
                return writer.ToString();
            }
        }
开发者ID:jlarsson,项目名称:MvcAssets,代码行数:28,代码来源:AssetsInjectorBase.cs


示例5: ParsedArguments

        public ParsedArguments(string[] args) {
            var p = new OptionSet {
                {"sum", "If set Sum will be calculated", _ => _SumValues = true},
                {"max", "If set show Max value", _ => _MaxValue = true},
                {"min", "If set show Min value", _ => _MinValue = true},
                {"dir=", "Output directory", dir => _OutputDirectory = GetValidPath(dir)}, {
                    "count=", "Count of items to be generated. This value is mandatory.", count => {
                        if (!_CountIsSet && int.TryParse(count, out _Count) && _Count > 0) {
                            _CountIsSet = true;
                        }
                    }
                }
            };

            p.Parse(args);

            if (!ArgsAreValid) {
                Trace.WriteLine("Parameter args does not contain valid value for count.");

                using (var stringWriter = new StringWriter()) {
                    p.WriteOptionDescriptions(stringWriter);
                    _ErrorMessage = stringWriter.ToString();
                }
            }
        }
开发者ID:matafonoff,项目名称:Brokeree.Test,代码行数:25,代码来源:ParsedArguments.cs


示例6: Boton_Excel_Dios_Click

        protected void Boton_Excel_Dios_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            Page page = new Page();
            HtmlForm form = new HtmlForm();
            GridView_Dios.DataSourceID = string.Empty;
            GridView_Dios.EnableViewState = false;
            GridView_Dios.AllowPaging = false;
            GridView_Dios.DataSource = LBPD.Logica_Mostrar_Precios();
            GridView_Dios.DataBind();
            page.EnableEventValidation = false;
            page.DesignerInitialize();
            page.Controls.Add(form);
            form.Controls.Add(GridView_Dios);
            page.RenderControl(htw);
            Response.Clear();
            Response.Buffer = true;
            Response.ContentType = "applicattion/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=data.xls");
            Response.Charset = "UTF-8";
            Response.ContentEncoding = Encoding.Default;
            Response.Write(sb.ToString());
            Response.End();
        }
开发者ID:Gutylic,项目名称:Proyecto-Alfa,代码行数:27,代码来源:Precios_Dios.aspx.cs


示例7: PrimitiveLiteral

 /// <summary>
 /// Returns the C# literal representation of a given primitive expression.
 /// (Useful for escaping strings)
 /// </summary>
 private static string PrimitiveLiteral(this string input)
 {
     var writer = new StringWriter();
     var provider = new CSharpCodeProvider();
     provider.GenerateCodeFromExpression(new CodePrimitiveExpression(input), writer, null);
     return writer.ToString();
 }
开发者ID:ChrisFulstow,项目名称:CSharpCodeGen,代码行数:11,代码来源:CodeGenerator.cs


示例8: HtmlToWord

        /// <summary>
        /// html标签导出到word
        /// </summary>
        /// <param name="html"></param>
        /// <param name="fileName">带后缀</param>
        /// <param name="IsWord2003"></param>
        /// <param name="ext"></param>
        public static void HtmlToWord(string html, string fileName, bool IsWord2003 = true)
        {
            try
            {
                HttpResponse response = System.Web.HttpContext.Current.Response;
                response.Clear();
                response.Buffer = false;
                response.Charset = "GB2312";
                response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, Encoding.UTF8));
                response.ContentEncoding = Encoding.GetEncoding("GB2312");

                response.ContentType = IsWord2003 ? "application/ms-word" : "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                //response.ContentType = "application/octet-stream";

                CultureInfo formatProvider = new CultureInfo("zh-CN", true);
                StringWriter writer = new StringWriter(formatProvider);

                response.Write(html);

                response.End();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:zhanglc8801,项目名称:WKT2015,代码行数:33,代码来源:RenderToWord.cs


示例9: ProcessRecord

        /// <summary>
        /// Processes the record.
        /// </summary>
        protected override void ProcessRecord()
        {
            this.WriteVerbose("Formatting log");
            using (var xmlReader = new StringReader(this.Log))
            {
                var xpath = new XPathDocument(xmlReader);
                using (var writer = new StringWriter())
                {
                    var transform = new XslCompiledTransform();
                    Func<string, string> selector = file => !Path.IsPathRooted(file) ? Path.Combine(Environment.CurrentDirectory, file) : file;
                    foreach (var fileToLoad in this.FormatFile.Select(selector))
                    {
                        this.WriteVerbose("Loading format file " + fileToLoad);
                        using (var stream = File.OpenRead(fileToLoad))
                        {
                            using (var reader = XmlReader.Create(stream))
                            {
                                transform.Load(reader);
                                transform.Transform(xpath, null, writer);
                            }
                        }
                    }

                    this.WriteObject(writer.GetStringBuilder().ToString(), false);
                }
            }
        }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:30,代码来源:FormatLog.cs


示例10: Invoke

		public bool Invoke(string[] args)
		{
			output = new StringWriter ();
			method_arg [0] = args;
			method_arg [1] = output;
			return (bool)ep.Invoke (null, method_arg);
		}
开发者ID:jakesays,项目名称:mono,代码行数:7,代码来源:compiler-tester.cs


示例11: SetUpWriter

		private void SetUpWriter()
		{
			sw = new StringWriter ();
			xtw = new XmlTextWriter (sw);
			xtw.QuoteChar = '\'';
			xtw.Formatting = Formatting.None;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:XmlSerializerTests.cs


示例12: GetCommands

 public static CoordinateCommand[] GetCommands(StringWriter trace)
 {
     return new[]
 {
     new CoordinateCommand(trace)    
 };
 }
开发者ID:lavige777,项目名称:ManyConsole,代码行数:7,代码来源:Multiple_dispatch_calls_dont_interfere_with_each_other.cs


示例13: UpdateOutputLogCommand

 private UpdateOutputLogCommand(IStorageBlockBlob outputBlob, Func<string, CancellationToken, Task> uploadCommand)
 {
     _outputBlob = outputBlob;
     _innerWriter = new StringWriter(CultureInfo.InvariantCulture);
     _synchronizedWriter = TextWriter.Synchronized(_innerWriter);
     _uploadCommand = uploadCommand;
 }
开发者ID:jonkelling,项目名称:azure-webjobs-sdk,代码行数:7,代码来源:UpdateOutputLogCommand.cs


示例14: btnExcel_Click

        protected void btnExcel_Click(object sender, EventArgs e)
        {
            //Create a dummy GridView
            GridView GridView1 = new GridView();
            GridView1.AllowPaging = false;
            GridView1.DataSource = BindGridView();
            GridView1.DataBind();

            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition",
             "attachment;filename=" + DateTime.Now.Year + "-Newly_Hired" + ".xls");
            Response.Charset = "";
            Response.ContentType = "application/vnd.ms-excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                //Apply text style to each Row
                GridView1.Rows[i].Attributes.Add("class", "textmode");
            }
            GridView1.RenderControl(hw);

            //style to format numbers to string
            string style = @"<style> .textmode { mso-number-format:\@; } </style>";
            Response.Write(style);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
        }
开发者ID:ismaeljaycarpio,项目名称:vs2013,代码行数:31,代码来源:NewlyHired.aspx.cs


示例15: Specify

        public override void Specify()
        {
            when("repeatedly dispatching a command", delegate
            {
                var trace = new StringWriter();

                arrange(delegate
                {
                    ConsoleCommandDispatcher.DispatchCommand(SomeProgram.GetCommands(trace), new[] { "move", "-x", "1", "-y", "2" }, new StringWriter());
                    ConsoleCommandDispatcher.DispatchCommand(SomeProgram.GetCommands(trace), new[] { "move", "-x", "3" }, new StringWriter());
                    ConsoleCommandDispatcher.DispatchCommand(SomeProgram.GetCommands(trace), new[] { "move", "-y", "4" }, new StringWriter());
                    ConsoleCommandDispatcher.DispatchCommand(SomeProgram.GetCommands(trace), new[] { "move" }, new StringWriter());
                });

                then("all parameters are evaluated independently", delegate
                {
                    Expect.That(trace.ToString()).ContainsInOrder(
                            "You walk to 1, 2 and find a maze of twisty little passages, all alike.",
                            "You walk to 3, 0 and find a maze of twisty little passages, all alike.",
                            "You walk to 0, 4 and find a maze of twisty little passages, all alike.",
                            "You walk to 0, 0 and find a maze of twisty little passages, all alike."
                        );
                });
            });
        }
开发者ID:lavige777,项目名称:ManyConsole,代码行数:25,代码来源:Multiple_dispatch_calls_dont_interfere_with_each_other.cs


示例16: TestConnectorSerialization

        public void TestConnectorSerialization()
        {
            var obj = new TwoInOneOutExpression();

            var tw = new StringWriter();
            using (var xw = XmlWriter.Create(tw))
            {
                xw.WriteStartElement("Node");
                obj.Serialize(xw);
                xw.WriteEndElement();
            }

            var sr = new StringReader(tw.ToString());
            using (var wr = XmlReader.Create(sr))
            {
                wr.ReadToFollowing("Node");
                var result = new TwoInOneOutExpression();
                result.Deserialize(wr);

                Assert.AreEqual(obj.Id, result.Id);
                Assert.AreEqual(obj.Connector1In.Id, result.Connector1In.Id);
                Assert.AreEqual(obj.Connector2In.Id, result.Connector2In.Id);
                Assert.AreEqual(obj.ConnectorOut.Id, result.ConnectorOut.Id);
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:25,代码来源:TwoInOneOutExpressionTests.cs


示例17: Generate

        public static string Generate(this ICalculationCodeGenerator codeGenerator, ICalculationComponent component)
        {
            var writer = new StringWriter();
            codeGenerator.Generate(component, writer);

            return writer.ToString();
        }
开发者ID:ibrahimbensalah,项目名称:XmallSteps,代码行数:7,代码来源:Class1.cs


示例18: AsyncFieldIndex1

        public void AsyncFieldIndex1()
        {
            var engine = new FileHelperAsyncEngine(typeof (SampleType));

            var sw = new StringWriter();
            engine.BeginWriteStream(sw);

            engine[0] = new DateTime(2003, 2, 1);
            engine[1] = "B";
            engine[2] = 18;

            engine.WriteNextValues();

            engine.Close();

            engine.BeginReadString(sw.GetStringBuilder().ToString());
            engine.ReadNext();

            Assert.AreEqual(new DateTime(2003, 2, 1), engine[0]);
            Assert.AreEqual("B", engine[1]);
            Assert.AreEqual(18, engine[2]);

            Assert.AreEqual(new DateTime(2003, 2, 1), engine.LastRecordValues[0]);
            Assert.AreEqual("B", engine.LastRecordValues[1]);
            Assert.AreEqual(18, engine.LastRecordValues[2]);

            engine.ReadNext();

            Assert.IsNull(engine.LastRecord);
            Assert.IsNull(engine.LastRecordValues);
        }
开发者ID:abombss,项目名称:FileHelpers,代码行数:31,代码来源:WritersFieldIndexers.cs


示例19: Execute

        public override CommandResultCode Execute(IExecutionContext context, CommandArguments args)
        {
            if (!args.MoveNext()) {
                ProductInfo product = ProductInfo.Current;
                StringWriter writer = new StringWriter();
                writer.WriteLine("---------------------------------------------------------------------------");
                writer.WriteLine(" {0} {1} {2}", product.Title, product.Version, product.Copyright);
                writer.WriteLine();
                writer.WriteLine(" CloudB Admin is provided AS IS and comes with ABSOLUTELY NO WARRANTY");
                writer.WriteLine(" This is free software, and you are welcome to redistribute it under the");
                writer.WriteLine(" conditions of the Lesser GNU Public License.");
                writer.WriteLine("---------------------------------------------------------------------------");
                Out.Write(writer.ToString());
                return CommandResultCode.Success;
            }

            if (args.Current == "version") {
                //TODO:
            } else if (args.Current == "license") {
                Out.WriteLine("Lesser GNU Public License <http://www.gnu.org/licenses/lgpl.txt>");
                return CommandResultCode.Success;
            }

            return CommandResultCode.SyntaxError;
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:25,代码来源:AboutCommand.cs


示例20: parameterFieldMapJson

        /// <summary>
        /// Convert parameter list to json object
        /// </summary>
        public static string parameterFieldMapJson(parameters parms, string ProjectID, string QueryID)
        {
            StringWriter sw = new StringWriter();
            JsonTextWriter json = new JsonTextWriter(sw);

            json.WriteStartObject();
            json.WritePropertyName("results");
            json.WriteStartArray();
            json.WriteStartObject();
            // ProjectID and QueryID
            json.WritePropertyName("ProjectID");
            json.WriteValue(ProjectID);
            json.WritePropertyName("QueryID");
            json.WriteValue(QueryID);

            json.WritePropertyName("parameters");
            json.WriteRawValue(JsonConvert.SerializeObject(parms));

            json.WriteEndObject();
            json.WriteEndArray();
            json.WriteEndObject();

            json.Flush();
            sw.Flush();

            return sw.ToString();
        }
开发者ID:kstubs,项目名称:ProjFlx,代码行数:30,代码来源:Helper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IO.TempDirectory类代码示例发布时间:2022-05-26
下一篇:
C# IO.StringReader类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap