• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Json.JsonWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



JsonWriter类属于Jayrock.Json命名空间,在下文中一共展示了JsonWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Format

        public virtual void Format(object o, JsonWriter writer)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");

            if (JNull.LogicallyEquals(o))
            {
                FormatNull(o, writer);
                return;
            }

            //
            // Handle primitive mapping specially.
            //

            switch (Type.GetTypeCode(o.GetType()))
            {
                case TypeCode.Byte    : FormatByte((byte) o, writer);       return;
                case TypeCode.Int16   : FormatInt16((short) o, writer);     return;
                case TypeCode.Int32   : FormatInt32((int) o, writer);       return;
                case TypeCode.Int64   : FormatInt64((long) o, writer);      return;
                case TypeCode.Decimal : FormatDecimal((decimal) o, writer); return;
                case TypeCode.Single  : FormatSingle((float) o, writer);    return;
                case TypeCode.Double  : FormatDouble((double) o, writer);   return;
                case TypeCode.Boolean : FormatBoolean((bool) o, writer);    return;
                case TypeCode.String  : FormatString((string) o, writer);   return;
            }
                    
            //
            // For all other types, go through a method that can be
            // overridden by subtypes.
            //

            FormatOther(o, writer);
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:35,代码来源:JsonFormatter.cs


示例2: Playback

        public void Playback(JsonWriter writer)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");

            writer.WriteFromReader(CreatePlayer());
        }
开发者ID:ashou1986,项目名称:top4net,代码行数:7,代码来源:JsonRecorder.cs


示例3: WritePhoneNumber

 private static void WritePhoneNumber(JsonWriter writer, string location, string number)
 {
     writer.WriteStartObject();      //  {
     writer.WriteMember("Location"); //      "Location" : 
     writer.WriteString(location);   //          "...", 
     writer.WriteMember("Number");   //      "Number" :
     writer.WriteString(number);     //          "..."
     writer.WriteEndObject();        //  }
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:9,代码来源:Program.cs


示例4: ArgumentNullException

        void IJsonExportable.Export(ExportContext context, JsonWriter writer)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            if (writer == null)
                throw new ArgumentNullException("writer");

            writer.WriteNull();
        }
开发者ID:ashou1986,项目名称:top4net,代码行数:10,代码来源:JsonNull.cs


示例5: FormatOther

        protected virtual void FormatOther(object o, JsonWriter writer)
        {
            //
            // If the value is is JSON-aware then let it do the job.
            //

            IJsonFormattable jsonFormattable = o as IJsonFormattable;

            if (jsonFormattable != null)
            {
                FormatFormattable(jsonFormattable, writer);
                return;
            }

            //
            // If the value is a dictionary then encode it as a JSON
            // object.
            //

            IDictionary dictionary = o as IDictionary;

            if (dictionary != null)
            {
                FormatDictionary(dictionary, writer);
                return;
            }

            //
            // If the value is enumerable then encode it as a JSON
            // array.
            //

            IEnumerable enumerable = o as IEnumerable;

            if (enumerable != null)
            {
                FormatEnumerable(enumerable, writer);
                return;
            }

            //
            // For all other types, write out its string representation as a
            // simple JSON string.
            //
            
            writer.WriteString(Convert.ToString(o, CultureInfo.InvariantCulture));
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:47,代码来源:JsonFormatter.cs


示例6: Process

        public virtual void Process(JsonReader request, JsonWriter response)
        {
            if (request == null)
                throw new ArgumentNullException("request");

            if (response == null)
                throw new ArgumentNullException("response");

            IDictionary requestObject;

            try
            {
                requestObject = ParseRequest(request);
            }
            catch (BadRequestException e)
            {
                requestObject = e.Request as IDictionary;

                WriteResponse(
                    CreateResponse(requestObject, /* result */ null,
                        OnError(e.InnerException, requestObject)),
                    response);

                return;
            }

            IDictionary responseObject = Invoke(requestObject);
            WriteResponse(responseObject, response);
        }
开发者ID:madalingavanarescu,项目名称:jayrock,代码行数:29,代码来源:JsonRpcDispatcher.cs


示例7: Export

            public void Export(ExportContext context, JsonWriter writer, object source)
            {
                if (context == null) throw new ArgumentNullException("context");
                if (writer == null) throw new ArgumentNullException("writer");
                if (source == null) throw new ArgumentNullException("source");

                object value = _property.GetValue(source);
                
                if (JsonNull.LogicallyEquals(value) || value.Equals(_defaultValue))
                    return;

                writer.WriteMember(_property.Name);
                context.Export(value, writer);
            }
开发者ID:s7loves,项目名称:pesta,代码行数:14,代码来源:JsonDefaultValueAttribute.cs


示例8: Export

 public override void Export(object value, JsonWriter writer)
 {
     ExportCalled = true;
     base.Export(value, writer);
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:5,代码来源:TestJsonRpcDispatcher.cs


示例9: Export

        protected virtual void Export(ExportContext context, JsonWriter writer)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            if (writer == null)
                throw new ArgumentNullException("writer");

            writer.WriteStartObject();
            
            foreach (string name in NameIndexList)
            {
                writer.WriteMember(name);    
                context.Export(InnerHashtable[name], writer);
            }

            writer.WriteEndObject();
        }
开发者ID:s7loves,项目名称:pesta,代码行数:18,代码来源:JsonObject.cs


示例10: FormatDouble

 protected virtual void FormatDouble(double value, JsonWriter writer)
 {
     writer.WriteNumber(value.ToString(CultureInfo.InvariantCulture));
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:4,代码来源:JsonFormatter.cs


示例11: Export

        public void Export(JsonWriter writer)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");

            writer.WriteStartObject();
            
            foreach (string name in NameIndexList)
            {
                writer.WriteMember(name);    
                writer.WriteValue(InnerHashtable[name]);
            }

            writer.WriteEndObject();
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:15,代码来源:JsonObject.cs


示例12: WriteRssToJson

 private static void WriteRssToJson(Channel channel, JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WriteMember("title");
     writer.WriteString(channel.title);
     writer.WriteMember("link");
     writer.WriteString(channel.link);
     writer.WriteMember("items");
     writer.WriteStartArray();
     foreach (Item item in channel.item)
         WriteRssToJson(item, writer);
     writer.WriteEndArray();
     writer.WriteEndObject();
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:14,代码来源:Program.cs


示例13: FormatEnumerable

 protected virtual void FormatEnumerable(IEnumerable enumerable, JsonWriter writer)
 {
     writer.WriteArray(enumerable);
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:4,代码来源:JsonFormatter.cs


示例14: Export

        protected virtual void Export(ExportContext context, JsonWriter writer)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            if (writer == null)
                throw new ArgumentNullException("writer");

            writer.WriteStartArray();

            foreach (object value in this)
                context.Export(value, writer);

            writer.WriteEndArray();
        }
开发者ID:GroupXTech,项目名称:Yatse2,代码行数:15,代码来源:JsonArray.cs


示例15: Export

 public void Export(object value, JsonWriter writer)
 {
     ExportCalled = true;
     JsonConvert.Export(value, writer);
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:5,代码来源:TestJsonRpcDispatcher.cs


示例16: Format

        public virtual void Format(object o, JsonWriter writer)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");

            if (JNull.LogicallyEquals(o))
            {
                FormatNull(o, writer);
                return;
            }

            //
            // Handle primitive mapping specially.
            //

            switch (Type.GetTypeCode(o.GetType()))
            {
                case TypeCode.Byte    : FormatByte((byte) o, writer);       return;
                case TypeCode.Int16   : FormatInt16((short) o, writer);     return;
                case TypeCode.Int32   : FormatInt32((int) o, writer);       return;
                case TypeCode.Int64   : FormatInt64((long) o, writer);      return;
                case TypeCode.Decimal : FormatDecimal((decimal) o, writer); return;
                case TypeCode.Single  : FormatSingle((float) o, writer);    return;
                case TypeCode.Double  : FormatDouble((double) o, writer);   return;
                case TypeCode.Boolean : FormatBoolean((bool) o, writer);    return;
                case TypeCode.String  : FormatString((string) o, writer);   return;
            }
                    
            //
            // If the value is is JSON-aware then let it do the job.
            //

            IJsonFormattable jsonFormattable = o as IJsonFormattable;

            if (jsonFormattable != null)
            {
                FormatFormattable(jsonFormattable, writer);
                return;
            }

            //
            // If the value is a dictionary then encode it as a JSON
            // object.
            //

            IDictionary dictionary = o as IDictionary;

            if (dictionary != null)
            {
                FormatDictionary(dictionary, writer);
                return;
            }

            //
            // If the value is enumerable then encode it as a JSON
            // array.
            //

            IEnumerable enumerable = o as IEnumerable;

            if (enumerable != null)
            {
                FormatEnumerable(enumerable, writer);
                return;
            }

            //
            // For all other types, write out its string representation as a
            // simple JSON string.
            //

            FormatCustom(o, writer);
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:73,代码来源:JsonFormatter.cs


示例17: FormatString

 protected virtual void FormatString(string value, JsonWriter writer)
 {
     writer.WriteString(value);
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:4,代码来源:JsonFormatter.cs


示例18: FormatBoolean

 protected virtual void FormatBoolean(bool value, JsonWriter writer)
 {
     writer.WriteBoolean(value);
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:4,代码来源:JsonFormatter.cs


示例19: WriteResponse

        protected virtual void WriteResponse(IDictionary response, JsonWriter output)
        {
            if (response == null)
                throw new ArgumentNullException("response");

            if (output == null)
                throw new ArgumentNullException("output");

            JsonExporter(response, output);
        }
开发者ID:madalingavanarescu,项目名称:jayrock,代码行数:10,代码来源:JsonRpcDispatcher.cs


示例20: Init

 public void Init()
 {
     _writer = new EmptyJsonWriter();
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:4,代码来源:TestJsonWriterBase.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Conversion.ImportContext类代码示例发布时间:2022-05-26
下一篇:
C# Json.JsonTextWriter类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap