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


C# JsonTextWriter.WriteEnd方法代码示例

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


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

示例1: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     string reVal = string.Empty;
     context.Response.ContentType = "text/plain";
     IEnumerable<ADM_USER> list = from m in etMgr.ADM_USER.OfType<ADM_USER>()
                                  select m;
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     using (JsonWriter jsonWriter = new JsonTextWriter(sw))
     {
         jsonWriter.Formatting = Formatting.Indented;
         jsonWriter.WriteStartArray();
         foreach (ADM_USER m in list)
         {
             jsonWriter.WriteStartObject();
             jsonWriter.WritePropertyName("name");
             jsonWriter.WriteValue(string.IsNullOrEmpty(m.REAL_NAME) ? m.USERNAME : m.REAL_NAME);
             jsonWriter.WritePropertyName("id");
             jsonWriter.WriteValue(m.USER_ID);
             jsonWriter.WriteEndObject();
         }
         jsonWriter.WriteEnd();
     }
     reVal = sb.ToString();
     context.Response.Write(reVal);
 }
开发者ID:mxm2005,项目名称:oacrm,代码行数:26,代码来源:GetUsers.ashx.cs

示例2: Main

 static void Main(string[] args)
 {
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     using (JsonWriter writer = new JsonTextWriter(sw))
     {
         writer.Formatting = Newtonsoft.Json.Formatting.Indented;
         writer.WriteStartObject();
         writer.WritePropertyName("CPU");
         writer.WriteValue("Intel");
         writer.WritePropertyName("PSU");
         writer.WriteValue("500W");
         writer.WritePropertyName("Drives");
         writer.WriteStartArray();
         writer.WriteValue("DVD read/writer");
         writer.WriteComment("(broken)");
         writer.WriteValue("500 gigabyte hard drive");
         writer.WriteValue("200 gigabype hard drive");
         writer.WriteEnd();
         writer.WriteEndObject();
     }
     File.WriteAllText(Environment.CurrentDirectory + "/rhcdata.json", sw.ToString());
     Console.WriteLine(sw.ToString());
     Console.ReadLine();
 }
开发者ID:MaurodeLyon,项目名称:Huiswerk-CSharp,代码行数:25,代码来源:Program.cs

示例3: WriteChildren

 private void WriteChildren(Dictionary<string, TreeElement> children, JsonTextWriter writer)
 {
     writer.WriteStartObject();
     foreach (var child in children) {
         writer.WritePropertyName(child.Key);
         WriteFrame(child.Value, writer);
     }
     writer.WriteEnd();
 }
开发者ID:kogir,项目名称:csharp-stackvis,代码行数:9,代码来源:IcicleWriter.cs

示例4: Start

        public bool Start(string context)
        {
            this.context = context;
            string uri = baseURI + @"start/";
            string method = "POST";
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
 
            using (JsonWriter jsonWriter = new JsonTextWriter(sw))
            {
                jsonWriter.Formatting = Formatting.Indented;
 
                jsonWriter.WriteStartObject();
                jsonWriter.WritePropertyName("context");
                jsonWriter.WriteValue(this.context);
                jsonWriter.WritePropertyName("participants");
                jsonWriter.WriteStartArray();
                jsonWriter.WriteStartObject();
                jsonWriter.WritePropertyName("name");
                // use the current window user
                jsonWriter.WriteValue(Environment.UserName);
                jsonWriter.WritePropertyName("id");
                // use the computer name + windows user name
                jsonWriter.WriteValue(Environment.MachineName + "-" + Environment.UserName);
                jsonWriter.WriteEndObject();
                jsonWriter.WriteEnd();
                jsonWriter.WriteEndObject();
            }
            string json = sb.ToString();
            
            HttpWebRequest req = WebRequest.Create(uri) as HttpWebRequest;
            req.KeepAlive = false;
            req.Method = method;
            byte[] buffer = Encoding.ASCII.GetBytes(json);
            req.ContentLength = buffer.Length;
            req.ContentType = "application/json";
            Stream PostData = req.GetRequestStream();
            PostData.Write(buffer, 0, buffer.Length);
            PostData.Close();

            HttpWebResponse resp = req.GetResponse() as HttpWebResponse;
            StreamReader tr = new StreamReader(resp.GetResponseStream());
            json = tr.ReadToEnd();            
            Dictionary<string, string> respValues = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
            if (respValues.ContainsKey("status") && respValues["status"] == "success")
            {
                this.dialogueID = respValues["dlg_id"];
                this.IsRunning = true;
                return true;
            }
            return false;
        }
开发者ID:cdbean,项目名称:CAGA,代码行数:52,代码来源:DialogueAgent.cs

示例5: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();

             var oSB = new StringBuilder();
             var oSW = new StringWriter(oSB);

             using (JsonWriter oWriter = new JsonTextWriter(oSW))
             {
            oWriter.Formatting = Formatting.Indented;

            oWriter.WriteStartObject();

            if (IsAuthenticated && ApplicationContext.IsStaff)
            {
               oWriter.WritePropertyName("results");
               oWriter.WriteStartArray();

               if (!string.IsNullOrEmpty(Request.QueryString["q"]))
               {
                  var sQuery = Request.QueryString["q"];
                  DataAccess.Log = new DebugTextWriter();

                  var oResults = DataAccess.fn_Producer_GetCustomerLookup();
                  oResults = oResults.Where(row => (row.FirstName + " " + row.LastName + " (" + row.Username + ")").Contains(sQuery))
                                     .Distinct().Take(30);

                  foreach (var oResult in oResults)
                  {
                     oWriter.WriteStartObject();
                     oWriter.WritePropertyName("id");
                     oWriter.WriteValue(oResult.MPUserID.ToString());
                     oWriter.WritePropertyName("name");
                     oWriter.WriteValue(string.Format("{0} {1} ({2})", oResult.FirstName, oResult.LastName, oResult.Username));
                     oWriter.WriteEndObject();
                  }

                  oWriter.WriteEnd();
               }
            }

            oWriter.WriteEndObject();
             }

             Response.ContentType = "application/json";
             Response.Write(oSB.ToString());
             Response.End();
        }
开发者ID:psychotiic,项目名称:speedyspots,代码行数:48,代码来源:ajax-customer-lookup.aspx.cs

示例6: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     string reVal = string.Empty;
     try
     {
         context.Response.ContentType = "text/plain";
         IEnumerable<MENU> list = from m in etMgr.MENU.OfType<MENU>()
                                  where m.PARENT_ID == 0
                                  select m;
         StringBuilder sb = new StringBuilder();
         StringWriter sw = new StringWriter(sb);
         using (JsonWriter jsonWriter = new JsonTextWriter(sw))
         {
             jsonWriter.Formatting = Formatting.Indented;
             jsonWriter.WriteStartArray();
             foreach (MENU m in list)
             {
                 jsonWriter.WriteStartObject();
                 jsonWriter.WritePropertyName("name");
                 jsonWriter.WriteValue(m.NAME);
                 jsonWriter.WritePropertyName("id");
                 jsonWriter.WriteValue(m.MENU_ID);
                 jsonWriter.WritePropertyName("url");
                 jsonWriter.WriteValue(m.URL);
                 jsonWriter.WritePropertyName("target");
                 jsonWriter.WriteValue(string.IsNullOrEmpty(m.TARGET.Trim()) ? "_parent" : m.TARGET);
                 if (etMgr.MENU.Count(me => me.PARENT_ID == m.MENU_ID) > 0)
                 {
                     jsonWriter.WritePropertyName("nodes");
                     sb.Append(GetChildStr(m.MENU_ID));
                 }
                 jsonWriter.WriteEndObject();
             }
             jsonWriter.WriteEnd();
         }
         reVal = sb.ToString();
     }
     catch (Exception ex)
     {
         Com.Mxm.WriteTxt.WriteText(ex.Message);
     }
     finally
     {
         etMgr.Dispose();
     }
     context.Response.Write(reVal);
 }
开发者ID:mxm2005,项目名称:oacrm,代码行数:47,代码来源:GetMenu.ashx.cs

示例7: MapPropertiesFromAttributes

		internal JObject MapPropertiesFromAttributes()
		{
			int seen;
			if (this.SeenTypes.TryGetValue(this._type, out seen) && seen > MaxRecursion)
				return JObject.Parse("{}");


			var sb = new StringBuilder();
			using (StringWriter sw = new StringWriter(sb))
			using (JsonWriter jsonWriter = new JsonTextWriter(sw))
			{

				jsonWriter.WriteStartObject();
				{
					this.WriteProperties(jsonWriter);
				}
				jsonWriter.WriteEnd();
				return JObject.Parse(sw.ToString());
			}
		}
开发者ID:radiosterne,项目名称:elasticsearch-net,代码行数:20,代码来源:TypeMappingWriter.cs

示例8: AuthRequest

        public AuthRequest(string _user, string _password, string _sku)
        {
            user = _user;
            password = _password;
            sku = _sku;

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            JsonWriter jsonWriter = new JsonTextWriter(sw);

            jsonWriter.Formatting = Formatting.None;
            jsonWriter.WriteStartObject();
            jsonWriter.WritePropertyName("priorityLevel");
            jsonWriter.WriteValue(6);

            jsonWriter.WritePropertyName("sku");
            jsonWriter.WriteValue(sku);
            jsonWriter.WritePropertyName("clientVersion");
            jsonWriter.WriteValue(3);
            jsonWriter.WritePropertyName("method");
            jsonWriter.WriteValue("nucemail");
            jsonWriter.WritePropertyName("macAddress");
            jsonWriter.WriteValue("38:2c:4a:6e:14:05");
            jsonWriter.WritePropertyName("locale");
            jsonWriter.WriteValue("en-US");

                jsonWriter.WritePropertyName("identification");
                jsonWriter.WriteStartObject();
                    jsonWriter.WritePropertyName("user");
                    jsonWriter.WriteValue(user);
                    jsonWriter.WritePropertyName("password");
                    jsonWriter.WriteValue(password);
                    jsonWriter.WriteEndObject();
            jsonWriter.WriteEnd();

            Body = sb.ToString();
        }
开发者ID:coder2084,项目名称:RestClient,代码行数:37,代码来源:AuthRequest.cs

示例9: WriteRawInObject

    public void WriteRawInObject()
    {
      StringBuilder sb = new StringBuilder();
      StringWriter sw = new StringWriter(sb);

      using (JsonWriter jsonWriter = new JsonTextWriter(sw))
      {
        jsonWriter.Formatting = Formatting.Indented;

        jsonWriter.WriteStartObject();
        jsonWriter.WriteRaw(@"""PropertyName"":[1,2,3,4,5]");
        jsonWriter.WriteEnd();
      }

      string expected = @"{""PropertyName"":[1,2,3,4,5]}";
      string result = sb.ToString();

      Assert.AreEqual(expected, result);
    }
开发者ID:RedBanies3ofThem,项目名称:tradelink.afterlife,代码行数:19,代码来源:JsonTextWriterTest.cs

示例10: Indenting

    public void Indenting()
    {
      StringBuilder sb = new StringBuilder();
      StringWriter sw = new StringWriter(sb);

      using (JsonWriter jsonWriter = new JsonTextWriter(sw))
      {
        jsonWriter.Formatting = Formatting.Indented;

        jsonWriter.WriteStartObject();
        jsonWriter.WritePropertyName("CPU");
        jsonWriter.WriteValue("Intel");
        jsonWriter.WritePropertyName("PSU");
        jsonWriter.WriteValue("500W");
        jsonWriter.WritePropertyName("Drives");
        jsonWriter.WriteStartArray();
        jsonWriter.WriteValue("DVD read/writer");
        jsonWriter.WriteComment("(broken)");
        jsonWriter.WriteValue("500 gigabyte hard drive");
        jsonWriter.WriteValue("200 gigabype hard drive");
        jsonWriter.WriteEnd();
        jsonWriter.WriteEndObject();
        Assert.AreEqual(WriteState.Start, jsonWriter.WriteState);
      }

      // {
      //   "CPU": "Intel",
      //   "PSU": "500W",
      //   "Drives": [
      //     "DVD read/writer"
      //     /*(broken)*/,
      //     "500 gigabyte hard drive",
      //     "200 gigabype hard drive"
      //   ]
      // }

      string expected = @"{
  ""CPU"": ""Intel"",
  ""PSU"": ""500W"",
  ""Drives"": [
    ""DVD read/writer""
    /*(broken)*/,
    ""500 gigabyte hard drive"",
    ""200 gigabype hard drive""
  ]
}";
      string result = sb.ToString();

      Assert.AreEqual(expected, result);
    }
开发者ID:RedBanies3ofThem,项目名称:tradelink.afterlife,代码行数:50,代码来源:JsonTextWriterTest.cs

示例11: QuoteChar

    public void QuoteChar()
    {
      StringWriter sw = new StringWriter();
      JsonTextWriter writer = new JsonTextWriter(sw);
      writer.Formatting = Formatting.Indented;
      writer.QuoteChar = '\'';

      writer.WriteStartArray();

      writer.WriteValue(new DateTime(2000, 1, 1, 1, 1, 1, DateTimeKind.Utc));
      writer.WriteValue(new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.Zero));

      writer.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat;
      writer.WriteValue(new DateTime(2000, 1, 1, 1, 1, 1, DateTimeKind.Utc));
      writer.WriteValue(new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.Zero));

      writer.DateFormatString = "yyyy gg";
      writer.WriteValue(new DateTime(2000, 1, 1, 1, 1, 1, DateTimeKind.Utc));
      writer.WriteValue(new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.Zero));

      writer.WriteValue(new byte[] { 1, 2, 3 });
      writer.WriteValue(TimeSpan.Zero);
      writer.WriteValue(new Uri("http://www.google.com/"));
      writer.WriteValue(Guid.Empty);

      writer.WriteEnd();

      Assert.AreEqual(@"[
  '2000-01-01T01:01:01Z',
  '2000-01-01T01:01:01+00:00',
  '\/Date(946688461000)\/',
  '\/Date(946688461000+0000)\/',
  '2000 A.D.',
  '2000 A.D.',
  'AQID',
  '00:00:00',
  'http://www.google.com/',
  '00000000-0000-0000-0000-000000000000'
]", sw.ToString());
    }
开发者ID:RedBanies3ofThem,项目名称:tradelink.afterlife,代码行数:40,代码来源:JsonTextWriterTest.cs

示例12: uploadFileResult

 //把返回值编译成json格式
 public string uploadFileResult(string result)
 {
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     using (JsonWriter jswriter = new JsonTextWriter(sw))
     {
         jswriter.Formatting = Formatting.Indented;
         jswriter.WriteStartObject();
         jswriter.WritePropertyName("result");
         jswriter.WriteValue(result);
         jswriter.WriteEnd();
     }
     return sb.ToString();
 }
开发者ID:scutsky,项目名称:iyuewan,代码行数:15,代码来源:UploadFile.ashx.cs

示例13: ModsToJson

 private string ModsToJson(List<Mod> mods)
 {
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     using (JsonWriter writer = new JsonTextWriter(sw))
     {
         writer.Formatting = Formatting.Indented;
         writer.WriteComment("DO NOT EDIT THIS BY HAND WITHOUT KNOWING EXACTLY WHAT YOU ARE DOING" + Environment.NewLine + "THIS FILE IS CREATED BY MCM AND IS USED FOR KNOWING WHICH MODS ARE INSTALLED!");
         writer.WriteStartObject();
         writer.WritePropertyName("mods");
         writer.WriteStartArray();
         foreach (Mod mod in mods)
         {
             writer.WriteStartObject();
             writer.WritePropertyName("name");
             writer.WriteValue(mod.name);
             writer.WritePropertyName("path");
             writer.WriteValue(mod.path);
             writer.WritePropertyName("type");
             writer.WriteValue(mod.type);
             writer.WritePropertyName("level");
             writer.WriteValue(mod.level);
             writer.WritePropertyName("version");
             writer.WriteValue(mod.version.Key);
             writer.WriteEndObject();
         }
         writer.WriteEnd();
     }
     return sb.ToString();
 }
开发者ID:Northcode,项目名称:MCM-reboot,代码行数:30,代码来源:Main.cs

示例14: CreateJsonObject

		private string CreateJsonObject(IEnumerable<IMeasurement> measurements)
		{
			StringBuilder sb = new StringBuilder();
			StringWriter sw = new StringWriter(sb);
			JsonWriter writer = new JsonTextWriter(sw);
			using (writer)
			{
				writer.Formatting = Formatting.Indented;
				writer.WriteStartObject();
				foreach (IGrouping<string, IMeasurement> measurementByType in measurements.GroupBy(measurement => measurement.Type))
				{
					writer.WritePropertyName(measurementByType.Key + "s");
					writer.WriteStartArray();
					foreach (IMeasurement measurement in measurements.Where(m => m.Type == measurementByType.Key))
					{
						this.JsonWriteMeasurement(writer, measurement);
					}
					writer.WriteEnd();
				}
				writer.WriteEndObject();
			}
			return sb.ToString();
		}
开发者ID:airdye,项目名称:libratoSharp,代码行数:23,代码来源:MetricsManager.cs

示例15: SaveAnim

        public void SaveAnim(string name)
        {
            if (!Directory.Exists("blueprints\\anim"))
            { Directory.CreateDirectory("blueprints\\anim"); }

            FileStream fs = File.Open("blueprints\\anim\\" + name + ".json", FileMode.Create);
            StreamWriter sw = new StreamWriter(fs);
            JsonTextWriter jw = new JsonTextWriter(sw);
            jw.Formatting = Formatting.Indented;

            jw.WriteStartObject();
            //anim
            jw.WritePropertyName("animations");
            jw.WriteStartArray();
            foreach (Animation a in anims)
            {
                jw.WriteStartObject();

                jw.WritePropertyName("name");
                jw.WriteValue(a.name);
                jw.WritePropertyName("speed");
                jw.WriteValue(a.speed);
                jw.WritePropertyName("loop");
                jw.WriteValue(a.loopback);
                jw.WritePropertyName("frames");
                jw.WriteValue(a.frames.Count);

                //collision
                jw.WritePropertyName("collisionVolumes");
                jw.WriteStartArray();
                for (int i = 0; i < a.frames.Count; i++)
                {
                    if (a.collision[i].Count > 0)
                    {
                        jw.WriteStartObject();
                        jw.WritePropertyName("volumes");
                        jw.WriteStartArray();
                        foreach (CollisionList cl in a.collision[i])
                        {
                            jw.WriteStartObject();
                            jw.WritePropertyName("physical");
                            jw.WriteValue(cl.Physical);
                            jw.WritePropertyName("centerX");
                            jw.WriteValue(a.frames[i].Width / 2);
                            jw.WritePropertyName("centerY");
                            jw.WriteValue(a.frames[i].Height / 2);
                            jw.WritePropertyName("xpoints");
                            jw.WriteStartArray();
                            foreach (CollisionPoint p in cl.Nodes)
                            {
                                jw.WriteValue(p.X - (a.frames[i].Width / 2));
                            }
                            jw.WriteEnd();
                            jw.WritePropertyName("ypoints");
                            jw.WriteStartArray();
                            foreach (CollisionPoint p in cl.Nodes)
                            {
                                jw.WriteValue(p.Y - (a.frames[i].Height / 2));
                            }
                            jw.WriteEnd();
                            jw.WriteEnd();
                        }
                        jw.WriteEnd();
                        jw.WriteEnd();
                    }
                    else
                    {
                        jw.WriteWhitespace("");
                    }
                }
                jw.WriteEnd();
                // end anim
                jw.WriteEnd();
            }
            jw.WriteEnd();

            jw.WriteEnd();
            jw.Close();

            if (!Directory.Exists("images\\anim"))
            { Directory.CreateDirectory("images\\anim"); }

            if (!Directory.Exists("images\\anim\\" + name))
            { Directory.CreateDirectory("images\\anim\\" + name); }
            foreach (Animation a in anims)
            {
                if (!Directory.Exists("images\\anim\\" + name + "\\" + a.name))
                { Directory.CreateDirectory("images\\anim\\" + name + "\\" + a.name); }
                int frameNum = 0;
                foreach (Texture2D t in a.frames)
                {
                    Stream s = File.OpenWrite("images\\anim\\" + name + "\\" + a.name + "\\" + frameNum + ".png");
                    t.SaveAsPng(s, t.Width, t.Height);
                    s.Close();
                    frameNum++;
                }
            }
        }
开发者ID:DuncanKeller,项目名称:Level-Editor,代码行数:98,代码来源:AnimationForm.cs


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