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


C# JsonTextWriter.WriteRawValue方法代码示例

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


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

示例1: Save

        public void Save(IPersistable build)
        {
            using (var fileStream = new FileStream(Source, FileMode.Open, FileAccess.ReadWrite))
            {
                if (fileStream.Length > 0) //remove ] if we have content in file
                {
                    fileStream.Seek(-1, SeekOrigin.End);
                }
                using (var sw = new StreamWriter(fileStream)) //add item to array
                {
                    using (JsonWriter writer = new JsonTextWriter(sw))
                    {
                        if (sw.BaseStream.Position == 0) //begin array if this is first item
                        {
                            writer.WriteRawValue("[");
                        }
                        else //we are adding item to existing array
                        {
                            writer.WriteRawValue(",");
                        }

                        serializer.Serialize(writer, build.Data());

                        writer.WriteRawValue("]");
                    }
                }
            }
        }
开发者ID:abhijeetpathak,项目名称:BuildMonitor,代码行数:28,代码来源:BuildRepository.cs

示例2: 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

示例3: Serialize

        public void Serialize(JsonWriter writer)
        {
            if (string.IsNullOrWhiteSpace(MimeType) || string.IsNullOrWhiteSpace(Content))
                return;

            var sb = new StringBuilder();
            var sw = new StringWriter(sb);
            using (JsonWriter jw = new JsonTextWriter(sw))
            {
                jw.WritePropertyName(MimeType);

                jw.WriteStartObject();

                if (!string.IsNullOrWhiteSpace(Content))
                {
                    jw.WriteRawValue(Content);
                }

                jw.WriteEndObject();

                if (jw.WriteState == WriteState.Error)
                    sb.Clear();
            }
            writer.WriteRawValue(sb.ToString());
        }
开发者ID:Robin--,项目名称:swaggerwcf,代码行数:25,代码来源:Example.cs

示例4: StringWriter

 void do确定_Click(object sender, EventArgs e)
 {
     var __sw = new StringWriter();
     JsonWriter __writer = new JsonTextWriter(__sw);
     __writer.WriteStartArray();
     foreach (DataGridViewRow __行 in this.out值.Rows)
     {
         if (!__行.IsNewRow)
         {
             var __value = __行.Cells[0].Value == null ? "" : __行.Cells[0].Value.ToString();
             if (_元数据 != null)
             {
                 switch (_元数据.类型)
                 {
                     case "string":
                     case "字符串":
                         __writer.WriteValue(__value);
                         break;
                     default:
                         __writer.WriteRawValue(__value);
                         break;
                 }
             }
             else
             {
                 __writer.WriteRawValue(__value);
             }
         }
     }
     __writer.WriteEndArray();
     __writer.Flush();
     _值 = __sw.GetStringBuilder().ToString();
     this.DialogResult = DialogResult.OK;
 }
开发者ID:xiaomiwk,项目名称:K_tongyongfangwen,代码行数:34,代码来源:F列结构_编辑.cs

示例5: ToJson

 /// <summary>
 /// Serializes <see cref="Graphic"/> into JSON string.
 /// </summary>
 /// <param name="graphic">graphic to serialize into JSON.</param>
 /// <returns>string representation of the JSON object.</returns>
 public static string ToJson(this  Graphic graphic)
 {
     StringBuilder sb = new StringBuilder();
     using (StringWriter sw = new StringWriter(sb))
     {
         using (JsonWriter jw = new JsonTextWriter(sw))
         {
             if (graphic.Geometry != null)
             {
                 jw.WriteStartObject();
                 jw.WritePropertyName("geometry");
                 // Gets the JSON string representation of the Geometry.
                 jw.WriteRawValue(graphic.Geometry.ToJson());
                 jw.WriteEndObject();
             }
             if (graphic.Attributes.Count > 0)
             {
                 jw.WriteStartObject();
                 foreach (var item in graphic.Attributes)
                 {
                     jw.WritePropertyName(item.Key);
                     jw.WriteValue(item.Value);
                 }
                 jw.WriteEndObject();
             }
         }
         return sb.ToString();
     }
 }
开发者ID:jNery,项目名称:geoenrichment_wp8,代码行数:34,代码来源:GraphicExtension.cs

示例6: AddEntry

 public static void AddEntry(String displayName, String name, String id)
 {
     _catalog.configs[name] = "{\"displayName\":\""+displayName+"\",\"folder\":\"" + name + "\", \"id\":\"" + id + "\"}";
     using (StreamWriter sw = new StreamWriter(_configDirectory + "catalog.json"))
     {
         using (JsonTextWriter jw = new JsonTextWriter(sw))
         {
             jw.WriteRawValue(JsonConvert.SerializeObject(_catalog));
         }
     }
 }
开发者ID:websy85,项目名称:generic-rest-connector,代码行数:11,代码来源:Catalog.cs

示例7: GetOuterBoundaryMask

        public HttpResponseMessage GetOuterBoundaryMask()
        {
            var stringBuilder = new StringBuilder();
            var jsonTextWriter = new JsonTextWriter(new StringWriter(stringBuilder));
            var outerBoundaryGeoJson = _geoService.GetOuterBoundaryMaskGeoJson();
            jsonTextWriter.WriteRawValue(outerBoundaryGeoJson);

            var response = this.Request.CreateResponse(HttpStatusCode.OK);
            response.Content = new StringContent(stringBuilder.ToString(), Encoding.UTF8, "application/json");
            return response;
        }
开发者ID:StanleyGoldman,项目名称:NycDataVizualizations,代码行数:11,代码来源:ApiController.cs

示例8: WriteApi

        internal string WriteApi(Uri basePath, string servicePath, Type serviceType, Stack<Type> typeStack)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.WriteStartObject();
                writer.WritePropertyName("apiVersion");
                writer.WriteValue(serviceType.Assembly.GetName().Version.ToString());
                writer.WritePropertyName("swaggerVersion");
                writer.WriteValue(Globals.SWAGGER_VERSION);
                writer.WritePropertyName("basePath");
                writer.WriteValue(string.Format("{0}://{1}", basePath.Scheme, basePath.Authority));
                writer.WritePropertyName("resourcePath");
                writer.WriteValue(string.Format(servicePath));

                writer.WritePropertyName("apis");
                writer.WriteRawValue(WriteApis(_Mapper.FindMethods(servicePath, serviceType, typeStack)));

                writer.WritePropertyName("models");
                writer.WriteRawValue(WriteModels(typeStack));
            }
            return sb.ToString();
        }
开发者ID:mattmhersh,项目名称:WCFRestDemo,代码行数:24,代码来源:Serializer.cs

示例9: GetBoroughBoundaries

        public HttpResponseMessage GetBoroughBoundaries()
        {
            var stringBuilder = new StringBuilder();
            var jsonTextWriter = new JsonTextWriter(new StringWriter(stringBuilder));
            jsonTextWriter.WriteStartObject();
            foreach (var boroughBoundary in _geoService.GetBoroughBoundariesGeoJson())
            {
                jsonTextWriter.WritePropertyName(boroughBoundary.Key);
                jsonTextWriter.WriteRawValue(boroughBoundary.Value);
            }
            jsonTextWriter.WriteEndObject();

            var response = this.Request.CreateResponse(HttpStatusCode.OK);
            response.Content = new StringContent(stringBuilder.ToString(), Encoding.UTF8, "application/json");
            return response;
        }
开发者ID:StanleyGoldman,项目名称:NycDataVizualizations,代码行数:16,代码来源:ApiController.cs

示例10: ToJson

 internal override string ToJson()
 {
     StringBuilder sb = new StringBuilder();
     using (StringWriter sw = new StringWriter(sb))
     {
         using (JsonWriter jw = new JsonTextWriter(sw))
         {
             jw.WriteStartObject();
             if (Graphics != null && Graphics.Count > 0)
             {
                 jw.WritePropertyName("featureCollection");
                 jw.WriteRawValue(new FeatureSet(Graphics).ToJson());
             }
             jw.WriteEndObject();
         }
     }
     return sb.ToString();
 }
开发者ID:jNery,项目名称:aggregate_hotspots_wp8,代码行数:18,代码来源:FeatureSetLayer.cs

示例11: ToJsonString

        public string ToJsonString()
        {
            var sb = new StringBuilder();

            using(var sw = new StringWriter(sb))
            using(JsonWriter jw = new JsonTextWriter(sw))
            {
                jw.WriteStartArray();

                jw.WriteValue(FunctionName);
                jw.WriteStartArray();

                Argument.ForEach(a => jw.WriteRawValue(a.ToString()));

                jw.WriteEndArray();
                jw.WriteEndArray();
            }

            return sb.ToString();
        }
开发者ID:remotex,项目名称:CorrugatedIron,代码行数:20,代码来源:Not.cs

示例12: ToJson2

 /// <summary>
 /// Extension method for serializing <see cref="Envelope"/> into JSON object 
 /// as expected in context parameter of <see cref="AggregatePointsParameter"/>
 /// </summary>
 /// <param name="envelope"></param>
 /// <returns></returns>
 public static string ToJson2(this Envelope envelope)
 {
     StringBuilder sb = new StringBuilder();
     using (StringWriter sw = new StringWriter(sb))
     {
         using (JsonWriter jw = new JsonTextWriter(sw))
         {
             jw.WriteStartObject();
             jw.WritePropertyName("outExtent");
             jw.WriteRawValue(envelope.ToJson());
             if (envelope.SpatialReference != null && envelope.SpatialReference.WKID > 0)
             {
                 jw.WritePropertyName("outSR");
                 jw.WriteValue(envelope.SpatialReference.WKID.ToString(CultureInfo.InvariantCulture));
             }
             jw.WriteEndObject();
         }
     }
     return sb.ToString();
 }
开发者ID:jNery,项目名称:aggregate_hotspots_wp8,代码行数:26,代码来源:EnvelopeExtension.cs

示例13: WriteType

        internal string WriteType(Type t, Stack<Type> typeStack)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.WriteStartObject();

                var idValue = Helpers.GetDataContractNamePropertyValue(t) ?? t.FullName;
                writer.WritePropertyName("id");
                writer.WriteValue(idValue);

                writer.WritePropertyName("properties");
                writer.WriteRawValue(WriteProperties(t, typeStack));
            }
            return sb.ToString();
        }
开发者ID:mattmhersh,项目名称:WCFRestDemo,代码行数:17,代码来源:Serializer.cs

示例14: WriteRawValue

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

      using (JsonWriter jsonWriter = new JsonTextWriter(sw))
      {
        int i = 0;
        string rawJson = "[1,2]";

        jsonWriter.WriteStartObject();

        while (i < 3)
        {
          jsonWriter.WritePropertyName("d" + i);
          jsonWriter.WriteRawValue(rawJson);

          i++;
        }

        jsonWriter.WriteEndObject();
      }

      Assert.AreEqual(@"{""d0"":[1,2],""d1"":[1,2],""d2"":[1,2]}", sb.ToString());
    }
开发者ID:RedBanies3ofThem,项目名称:tradelink.afterlife,代码行数:25,代码来源:JsonTextWriterTest.cs

示例15: JsonTextWriter

        /// <summary>
        /// Serializes only the necessary components of the <see cref="PersistentResponse"/> to JSON
        /// using Json.NET's JsonTextWriter to improve performance.
        /// </summary>
        /// <param name="writer">The <see cref="System.IO.TextWriter"/> that receives the JSON serialization.</param>
        void IJsonWritable.WriteJson(TextWriter writer)
        {
            var jsonWriter = new JsonTextWriter(writer);
            jsonWriter.WriteStartObject();

            jsonWriter.WritePropertyName("C");
            jsonWriter.WriteValue(MessageId);

            if (Disconnect)
            {
                jsonWriter.WritePropertyName("D");
                jsonWriter.WriteValue(1);
            }

            if (TimedOut)
            {
                jsonWriter.WritePropertyName("T");
                jsonWriter.WriteValue(1);
            }

            if (GroupsToken != null)
            {
                jsonWriter.WritePropertyName("G");
                jsonWriter.WriteValue(GroupsToken);
            }

            if (LongPollDelay.HasValue)
            {
                jsonWriter.WritePropertyName("L");
                jsonWriter.WriteValue(LongPollDelay.Value);
            }

            jsonWriter.WritePropertyName("M");
            jsonWriter.WriteStartArray();

            Messages.Enumerate(m => !m.IsCommand && !ExcludeFilter(m),
                               m => jsonWriter.WriteRawValue(m.Value));

            jsonWriter.WriteEndArray();
            jsonWriter.WriteEndObject();
        }
开发者ID:stirno,项目名称:SignalR,代码行数:46,代码来源:PersistentResponse.cs


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