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


C# JsonWriter.WriteRawValue方法代码示例

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


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

示例1: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            Route route = (Route)value;
            writer.WriteStartObject();
            writer.WritePropertyName("id");
            writer.WriteValue(route.Id);
            writer.WritePropertyName("length");
            writer.WriteValue(route.Length);
            writer.WritePropertyName("line");
            writer.WriteRawValue(JsonConvert.SerializeObject(route.Line));
            writer.WritePropertyName("maxM");
            writer.WriteValue(route.MaxM);
            writer.WritePropertyName("minM");
            writer.WriteValue(route.MinM);
            writer.WritePropertyName("region");
            writer.WriteRawValue(JsonConvert.SerializeObject(route.Region));
            writer.WritePropertyName("parts");
            writer.WriteRawValue(JsonConvert.SerializeObject(route.Parts));

            writer.WritePropertyName("style");
            writer.WriteRawValue(JsonConvert.SerializeObject(route.Style));
            writer.WritePropertyName("type");
            writer.WriteValue(route.Type);
            writer.WritePropertyName("points");
            writer.WriteRawValue(JsonConvert.SerializeObject(route.Points));

            writer.WriteEndObject();
        }
开发者ID:SuperMap,项目名称:iClient-for-DotNet,代码行数:28,代码来源:RouteConverter.cs

示例2: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            PacketEffect effect = (PacketEffect)value;
                PacketEffectAttribute effectAttribute = effect.GetType().GetCustomAttribute<PacketEffectAttribute>();
                if (effectAttribute == null)
                    throw new NotSupportedException("All PacketEffect classes must have a PacketEffectAttribute !");

                writer.WriteStartObject();
                writer.WritePropertyName(effectAttribute.Name);
                writer.WriteStartObject();
                foreach (PropertyInfo info in value.GetType().GetProperties())
                {
                    string propertyName;
                    JsonPropertyAttribute propertyAttribute = info.GetCustomAttribute<JsonPropertyAttribute>();
                    if (propertyAttribute != null)
                        propertyName = propertyAttribute.PropertyName;
                    else
                        propertyName = info.Name;
                    writer.WritePropertyName(propertyName);

                    JsonConverterAttribute conversionAttribute = info.GetCustomAttribute<JsonConverterAttribute>();
                    if (conversionAttribute != null)
                        writer.WriteRawValue(JsonConvert.SerializeObject(info.GetValue(value), Formatting.None, (JsonConverter)Activator.CreateInstance(conversionAttribute.ConverterType)));
                    else
                        writer.WriteRawValue(JsonConvert.SerializeObject(info.GetValue(value)));
                }
                writer.WriteEndObject();
                writer.WriteEndObject();
        }
开发者ID:MarechalBanane,项目名称:RelentlessZero,代码行数:29,代码来源:Packets.cs

示例3: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value is string)
            {
                if (Value_RE.Match(value.ToString()).Success) 
                {
                    writer.WriteRawValue(value.ToString()); 
                }
                else
                {
                    string prms;
                    
                    switch (this.Name)
                    {
                        case "before":
                            prms = "el,type,action,extraParams,o";
                            break;
                        case "complete":
                            prms = "success,response,result,el,type,action,extraParams,o";
                            break;
                        default:
                            prms = "response,result,el,type,action,extraParams,o";
                            break;
                    }

                    value = TokenUtils.ReplaceRawToken(TokenUtils.ParseTokens(value.ToString(), this.OwnerControl));
                    writer.WriteRawValue(new JFunction((string)value, prms).ToScript()); 
                }
            }
        }
开发者ID:pgodwin,项目名称:Ext.net,代码行数:30,代码来源:DirectEventHandlerJsonConverter.cs

示例4: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value != null && value is ComponentListener)
            {
                ComponentListener componentListener = (ComponentListener)value;

                if (!componentListener.IsDefault)
                {
                    if (this.Owner is StateManagedItem)
                    {
                        componentListener.Owner = ((StateManagedItem)this.Owner).Owner;
                    }
                    else if (this.Owner is Control) 
                    {
                        componentListener.Owner = (Control)this.Owner;
                    }

                    componentListener.SetArgumentList(this.Owner.GetType().GetProperty(this.PropertyName));
                    
                    writer.WriteRawValue(new ClientConfig().Serialize(componentListener));
                    return;
                }
            }
            writer.WriteRawValue("{}");
        }
开发者ID:pgodwin,项目名称:Ext.net,代码行数:25,代码来源:ListenerJsonConverter.cs

示例5: WriteJson

 /// <summary>${WP_REST_RectConverter_method_WriteJson_D}</summary>
 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     Rect rect = (Rect)value;
     PointConverter ponitConverter = new PointConverter();
     writer.WriteStartObject();
     writer.WritePropertyName("rightBottom");
     writer.WriteRawValue(JsonConvert.SerializeObject(new Point(rect.Right,rect.Bottom), ponitConverter));
     writer.WritePropertyName("leftTop");
     writer.WriteRawValue(JsonConvert.SerializeObject(new Point(rect.Left, rect.Top), ponitConverter));
     writer.WriteEndObject();
 }
开发者ID:SuperMap,项目名称:iClient-for-Win8,代码行数:12,代码来源:RectConverter.cs

示例6: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value != null && value is Renderer)
            {
                string temp = ((Renderer)value).ToConfigString();

                if (temp.IsNotEmpty())
                {
                    writer.WriteRawValue(temp);
                    return;
                }
            }
            writer.WriteRawValue("null");
        }
开发者ID:pgodwin,项目名称:Ext.net,代码行数:14,代码来源:RendererJsonConverter.cs

示例7: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            switch ((ThreeStateBool)value)
            {
                case ThreeStateBool.False:
                    writer.WriteRawValue("false");
                    return;
                case ThreeStateBool.True:
                    writer.WriteRawValue("true");
                    return;
            }

            writer.WriteRawValue("undefined");
        }
开发者ID:pgodwin,项目名称:Ext.net,代码行数:14,代码来源:ThreeStateBoolJsonConverter.cs

示例8: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			ElasticQuery term = (ElasticQuery)value;
			if (term != null)
			{
				writer.WriteStartObject();

				writer.WriteRaw("\"from\": " + term.From);
				writer.WriteRaw(",\"size\": " + term.Size + ",");
				writer.WritePropertyName("query");
				serializer.Serialize(writer, term.Query);

				if (term.Fields != null && term.Fields.Count > 0)
				{
					writer.WritePropertyName("fields");
					writer.WriteStartArray();
					foreach (var field in term.Fields)
					{
						writer.WriteRawValue("\"" + field + "\"");
					}
					writer.WriteEndArray();
				}
				if (term.SortItems != null && term.SortItems.Count > 0)
				{
					writer.WritePropertyName("sort");
					writer.WriteStartObject();
					foreach (var sortItem in term.SortItems)
					{
					    if (sortItem != null)
					    {
					        writer.WritePropertyName(sortItem.FieldName);
					        writer.WriteValue(sortItem.SortType.ToString().ToLower());
					    }
					}

					writer.WriteEndObject();
				}

                //facets
                if (term.Facets != null)
                {
                    writer.WritePropertyName("facets");
                    serializer.Serialize(writer, term.Facets);
                }

                //hightlight
                if(term.Hightlight!=null)
                {
                    writer.WritePropertyName("highlight");
                    serializer.Serialize(writer,term.Hightlight);
                }

                if (term.Explain)
                {
                    writer.WriteRaw(",\"explain\": " + term.Explain.ToString().ToLower());
                }

				writer.WriteEndObject();
			}
		}
开发者ID:starckgates,项目名称:ElasticSearch.Net,代码行数:60,代码来源:ElasticQueryConverter.cs

示例9: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            TermsFilter term = (TermsFilter)value;
            if (term != null)
            {

                var stringBuilder = new StringBuilder();

                stringBuilder.Append("{    \"terms\" : {        \"" + term.Field + "\" : [");

                var i = 0;
                foreach (var t in term.Values)
                {
                    if (i > 0)
                    {
                        stringBuilder.Append(",");
                    }
                    stringBuilder.Append("\"" + t + "\"");
                    i++;
                }

                stringBuilder.Append("]");
//                stringBuilder.Append(",\"_cache\": " + term.Cache.ToString().ToLower());
                stringBuilder.Append("}}");

                writer.WriteRawValue(stringBuilder.ToString());
            }

        }
开发者ID:starckgates,项目名称:ElasticSearch.Net,代码行数:29,代码来源:TermsFilterConverter.cs

示例10: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var item = (LogEventInfoItem)value;

            writer.WriteStartObject();
            writer.WritePropertyName("ItemId");
            writer.WriteValue(item.ItemId);
            writer.WritePropertyName("SequenceId");
            writer.WriteValue(item.SequenceId);
            writer.WritePropertyName("TimeStamp");
            writer.WriteValue(new DateTimeOffset(item.DateTimeUtc));
            writer.WritePropertyName("Level");
            writer.WriteValue(item.Level.ToString());
            writer.WritePropertyName("Logger");
            writer.WriteValue(item.Logger);
            writer.WritePropertyName("Message");
            writer.WriteValue(item.Message);

            // exception?
            writer.WritePropertyName("ExceptionWrapper");
            var wrapper = item.GetExceptionWrapper();
            if (wrapper != null)
                writer.WriteRawValue(wrapper.ToJson());
            else
                writer.WriteValue((object)null);

            writer.WriteEndObject();
        }
开发者ID:mqmanpsy,项目名称:MetroLog,代码行数:28,代码来源:LogEventInfoItemConverter.cs

示例11: WriteJson

        public override JsonWriter WriteJson(JsonWriter writer)
        {
            if(Filters.Count > 0)
            {
                writer.WritePropertyName("inputs");
                writer.WriteStartObject();

                writer.WritePropertyName("bucket");
                writer.WriteValue(_bucket);

                writer.WritePropertyName("key_filters");
                writer.WriteStartArray();

                Filters.ForEach(f => writer.WriteRawValue(f.ToJsonString()));

                writer.WriteEndArray();
                writer.WriteEndObject();
            }
            else
            {
                writer.WritePropertyName("inputs");
                writer.WriteValue(_bucket);
            }

            return writer;
        }
开发者ID:taliesins,项目名称:CorrugatedIron,代码行数:26,代码来源:RiakBucketInput.cs

示例12: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     if (value is string)
     {
         writer.WriteRawValue(new JFunction((string)value).ToScript()); 
     }
 }
开发者ID:pgodwin,项目名称:Ext.net,代码行数:7,代码来源:FunctionJsonConverter.cs

示例13: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            IList items = (IList)value;

            if (value != null && items.Count > 0)
            {
                if (items.Count == 1 && !CanBeSingleItemArray(items[0]))
                {
                    Control item = (Control)items[0];

                    PanelBase pnl = item as PanelBase;

                    if (!item.Visible || (pnl != null && pnl.Hidden && pnl.ParentComponent is TabPanel))
                    {
                        writer.WriteNull();
                        return;
                    }

                    writer.WriteRawValue(this.Format(items[0] as Control));
                }
                else
                {
                    bool visible = false;

                    foreach (Observable item in items)
                    {
                        PanelBase pnl = item as PanelBase;
                        bool isTab = pnl != null && pnl.ParentComponent is TabPanel;

                        if (item.Visible && (!isTab || !pnl.Hidden))
                        {
                            visible = true;
                        }
                    }

                    if (visible)
                    {
                        writer.WriteStartArray();

                        foreach (Observable item in items)
                        {
                            PanelBase pnl = item as PanelBase;

                            bool isTab = pnl != null && pnl.ParentComponent is TabPanel;

                            if (item.Visible && (!isTab || !pnl.Hidden))
                            {
                                writer.WriteRawValue(this.Format(item));
                            }
                        }

                        writer.WriteEndArray();
                    }
                    else
                    {
                        writer.WriteNull();
                    }
                }
            }
        }
开发者ID:pgodwin,项目名称:Ext.net,代码行数:60,代码来源:ItemCollectionJsonConverter.cs

示例14: WriteJson

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			WildcardQuery term = (WildcardQuery)value;

			if (term != null)
				writer.WriteRawValue(string.Format("{{ wildcard: {{ \"{0}\" : {{ \"wildcard\" : \"{1}\", \"boost\":{2} }}}} }}", term.Field, term.WildCardPattern, term.Boost));
		}
开发者ID:starckgates,项目名称:ElasticSearch.Net,代码行数:7,代码来源:WildcardQueryConverter.cs

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


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