當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。