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


C# JsonTextWriter.ToString方法代码示例

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


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

示例1: Page_Load

        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.ContentType = "application/json";

            string programID = Request.QueryString["programID"];
            string recordOption = Request.QueryString["option"];
            bool success;

            if (User.IsInRole("recorder"))
            {
                success = uWiMP.TVServer.Recordings.RecordProgramById(Convert.ToInt32(programID), (Recordings.RecordingType)Convert.ToInt32(recordOption));
            }
            else
            {
                success = false;
            }

            using (JsonTextWriter jw = new JsonTextWriter())
            {
                jw.PrettyPrint = true;
                jw.WriteStartObject();
                jw.WriteMember("result");
                jw.WriteBoolean(success);
                jw.WriteEndObject();

                Response.Write(jw.ToString());
            }
        }
开发者ID:rndthoughts,项目名称:ipimpplus,代码行数:28,代码来源:RecordProgram.aspx.cs

示例2: Page_Load

        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.ContentType = "application/json";

            string programID = Request.QueryString["programID"];
            Program program = uWiMP.TVServer.Programs.GetProgramByProgramId(Convert.ToInt32(programID));
            Channel channel = uWiMP.TVServer.Channels.GetChannelByChannelId(program.IdChannel);

            string timetext = string.Format("<b>{0}-{1}</b><br>", program.StartTime.ToShortTimeString(), program.EndTime.ToShortTimeString());
            string title = program.Title == "" ? GetGlobalResourceObject("uWiMPStrings", "unknown_title").ToString() : program.Title;
            string episodeName = program.EpisodeName == "" ? timetext : timetext + "<b>" + program.EpisodeName + "</b><br>";
            string description = program.Description == "" ? GetGlobalResourceObject("uWiMPStrings", "description_not_found").ToString() : episodeName + program.Description;

            using (JsonTextWriter jw = new JsonTextWriter())
            {
                jw.PrettyPrint = true;
                jw.WriteStartObject();
                jw.WriteMember("title");
                jw.WriteString(title);
                jw.WriteMember("description");
                jw.WriteString(description);
                jw.WriteMember("channel");
                jw.WriteString(channel.DisplayName);
                jw.WriteMember("running");
                jw.WriteBoolean(program.IsRunningAt(DateTime.Now));
                jw.WriteMember("scheduled");
                jw.WriteBoolean(uWiMP.TVServer.Schedules.IsProgramScheduled(program));
                jw.WriteEndObject();

                Response.Write(jw.ToString());
            }
        }
开发者ID:rndthoughts,项目名称:ipimpplus,代码行数:32,代码来源:ProgramDetails.aspx.cs

示例3: Complex

        public void Complex()
        {
            const string input = @"{'menu': {
                'header': 'SVG Viewer',
                'items': [
                    {'id': 'Open'},
                    {'id': 'OpenNew', 'label': 'Open New'},
                    null,
                    {'id': 'ZoomIn', 'label': 'Zoom In'},
                    {'id': 'ZoomOut', 'label': 'Zoom Out'},
                    {'id': 'OriginalView', 'label': 'Original View'},
                    null,
                    {'id': 'Quality'},
                    {'id': 'Pause'},
                    {'id': 'Mute'},
                    null,
                    {'id': 'Find', 'label': 'Find...'},
                    {'id': 'FindAgain', 'label': 'Find Again'},
                    {'id': 'Copy'},
                    {'id': 'CopyAgain', 'label': 'Copy Again'},
                    {'id': 'CopySVG', 'label': 'Copy SVG'},
                    {'id': 'ViewSVG', 'label': 'View SVG'},
                    {'id': 'ViewSource', 'label': 'View Source'},
                    {'id': 'SaveAs', 'label': 'Save As'},
                    null,
                    {'id': 'Help'},
                    {'id': 'About', 'label': 'About Adobe CVG Viewer...'}
                ]
            }}";

            JsonTextReader reader = new JsonTextReader(new StringReader(input));
            JsonTextWriter writer = new JsonTextWriter();
            JsonRecorder.Record(reader).Playback(writer);
            Assert.AreEqual("{\"menu\":{\"header\":\"SVG Viewer\",\"items\":[{\"id\":\"Open\"},{\"id\":\"OpenNew\",\"label\":\"Open New\"},null,{\"id\":\"ZoomIn\",\"label\":\"Zoom In\"},{\"id\":\"ZoomOut\",\"label\":\"Zoom Out\"},{\"id\":\"OriginalView\",\"label\":\"Original View\"},null,{\"id\":\"Quality\"},{\"id\":\"Pause\"},{\"id\":\"Mute\"},null,{\"id\":\"Find\",\"label\":\"Find...\"},{\"id\":\"FindAgain\",\"label\":\"Find Again\"},{\"id\":\"Copy\"},{\"id\":\"CopyAgain\",\"label\":\"Copy Again\"},{\"id\":\"CopySVG\",\"label\":\"Copy SVG\"},{\"id\":\"ViewSVG\",\"label\":\"View SVG\"},{\"id\":\"ViewSource\",\"label\":\"View Source\"},{\"id\":\"SaveAs\",\"label\":\"Save As\"},null,{\"id\":\"Help\"},{\"id\":\"About\",\"label\":\"About Adobe CVG Viewer...\"}]}}", writer.ToString());
        }
开发者ID:bubbafat,项目名称:Hebo,代码行数:35,代码来源:TestJsonRecorder.cs

示例4: String

 public void String()
 {
     JsonRecorder recorder = new JsonRecorder();
     recorder.WriteString("Hello World");
     JsonTextWriter writer = new JsonTextWriter();
     recorder.Playback(writer);
     Assert.AreEqual("\"Hello World\"", writer.ToString());
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:8,代码来源:TestJsonRecorder.cs

示例5: WriteBoolean

 public void WriteBoolean()
 {
     JsonTextWriter writer = new JsonTextWriter(new StringWriter());
     writer.WriteBoolean(true);
     Assert.AreEqual("true", writer.ToString());
     
     writer = new JsonTextWriter(new StringWriter());
     writer.WriteBoolean(false);
     Assert.AreEqual("false", writer.ToString());
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:10,代码来源:TestJsonTextWriter.cs

示例6: ReturnBoolean

        static internal string ReturnBoolean(bool value)
        {
            JsonTextWriter jw = new JsonTextWriter();
            jw.PrettyPrint = true;
            jw.WriteStartObject();
            jw.WriteMember("result");
            jw.WriteBoolean(value);
            jw.WriteEndObject();

            return jw.ToString();
        }
开发者ID:rndthoughts,项目名称:ipimpplus,代码行数:11,代码来源:MPClientRemoting.cs

示例7: PrettyPrinting

 public void PrettyPrinting()
 {
     JsonTextWriter writer = new JsonTextWriter();
     writer.PrettyPrint = true;
     writer.WriteFromReader(new JsonTextReader(new StringReader("{'menu':{'id':'file','value':'File:','popup':{'menuitem':[{'value':'New','onclick':'CreateNewDoc()'},{'value':'Open','onclick':'OpenDoc()'},{'value':'Close','onclick':'CloseDoc()'}]}}}")));
     Assert.AreEqual(RewriteLines(@"{
     ""menu"": {
     ""id"": ""file"",
     ""value"": ""File:"",
     ""popup"": {
     ""menuitem"": [ {
         ""value"": ""New"",
         ""onclick"": ""CreateNewDoc()""
     }, {
         ""value"": ""Open"",
         ""onclick"": ""OpenDoc()""
     }, {
         ""value"": ""Close"",
         ""onclick"": ""CloseDoc()""
     } ]
     }
     }
     }"), writer.ToString() + Environment.NewLine);
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:24,代码来源:TestJsonTextWriter.cs

示例8: WriteValue

 private static string WriteValue(object value)
 {
     JsonTextWriter writer = new JsonTextWriter(new StringWriter());
     JsonConvert.Export(value, writer);
     return writer.ToString();
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:6,代码来源:TestJsonTextWriter.cs

示例9: WriteString

 private static void WriteString(string expected, string value)
 {
     JsonTextWriter writer = new JsonTextWriter(new StringWriter());
     writer.WriteString(value);
     Assert.AreEqual(expected, writer.ToString());
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:6,代码来源:TestJsonTextWriter.cs

示例10: WriteObject

 public void WriteObject()
 {
     JsonTextWriter writer = new JsonTextWriter(new StringWriter());
     writer.WriteStartObject();
     writer.WriteMember("Name");
     writer.WriteString("John Doe");
     writer.WriteMember("Salary");
     writer.WriteNumber(123456789);
     writer.WriteEndObject();
     Assert.AreEqual("{\"Name\":\"John Doe\",\"Salary\":123456789}", writer.ToString());
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:11,代码来源:TestJsonTextWriter.cs

示例11: WriteNumber

 public void WriteNumber()
 {
     JsonTextWriter writer = new JsonTextWriter(new StringWriter());
     writer.WriteNumber(123);
     Assert.AreEqual("[123]", writer.ToString());
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:6,代码来源:TestJsonTextWriter.cs

示例12: WriteNullValue

 public void WriteNullValue()
 {
     JsonTextWriter writer = new JsonTextWriter(new StringWriter());
     writer.WriteValue(JNull.Value);
     Assert.AreEqual("null", writer.ToString());
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:6,代码来源:TestJsonTextWriter.cs

示例13: WriteEmptyObject

 public void WriteEmptyObject()
 {
     JsonTextWriter writer = new JsonTextWriter(new StringWriter());
     writer.WriteStartObject();
     writer.WriteEndObject();
     Assert.AreEqual("{}", writer.ToString());
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:7,代码来源:TestJsonTextWriter.cs

示例14: WriteArray

 public void WriteArray()
 {
     JsonTextWriter writer = new JsonTextWriter(new StringWriter());
     writer.WriteStringArray(new object[] { 123, "Hello \"Old\" World", true });
     Assert.AreEqual("[\"123\",\"Hello \\\"Old\\\" World\",\"True\"]", writer.ToString());
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:6,代码来源:TestJsonTextWriter.cs

示例15: ConvertRequestToJson

        static internal string ConvertRequestToJson(uWiMP.TVServer.MPClient.Request request)
        {
            JsonTextWriter jw = new JsonTextWriter();
            jw.PrettyPrint = true;
            jw.WriteStartObject();
            jw.WriteMember("action");
            jw.WriteString(request.Action);
            jw.WriteMember("filter");
            jw.WriteString(request.Filter);
            jw.WriteMember("value");
            jw.WriteString(request.Value);
            jw.WriteMember("start");
            jw.WriteString(request.Start.ToString());
            jw.WriteMember("pagesize");
            jw.WriteString(request.PageSize.ToString());
            jw.WriteMember("shuffle");
            jw.WriteBoolean(request.Shuffle);
            jw.WriteMember("enqueue");
            jw.WriteBoolean(request.Enqueue);
            jw.WriteMember("tracks");
            jw.WriteString(request.Tracks);
            jw.WriteEndObject();

            return jw.ToString();
        }
开发者ID:rndthoughts,项目名称:ipimpplus,代码行数:25,代码来源:MPClientRemoting.cs


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