예제 #1
0
        /// <summary>
        /// 对象序列化
        /// </summary>
        /// <param name="toJsoner"></param>
        protected void toJson(fastCSharp.emit.jsonSerializer toJsoner)
        {
            toJsoner.UnsafeWriteNextName("msgtype");
            toJsoner.UnsafeToJsonNotNull(msgtype.ToString());
            toJsoner.UnsafeWriteNextName(msgtype.ToString());
            switch (msgtype)
            {
            case type.mpnews:
                toJsoner.UnsafeToJsonNotNull(mpnews);
                break;

            case type.text:
                toJsoner.UnsafeToJsonNotNull(text);
                break;

            case type.image:
                toJsoner.UnsafeToJsonNotNull(image);
                break;

            case type.voice:
                toJsoner.UnsafeToJsonNotNull(voice);
                break;

            case type.mpvideo:
                toJsoner.UnsafeToJsonNotNull(mpvideo);
                break;

            case type.wxcard:
                toJsoner.UnsafeToJsonNotNull(wxcard);
                break;
            }
            toJsoner.UnsafeCharStream.Write('}');
        }
예제 #2
0
        internal static void ToJson(fastCSharp.emit.jsonSerializer toJsoner, memberMapValue <valueType> value)
        {
            if (value.Value == null)
            {
                fastCSharp.web.ajax.WriteNull(toJsoner.CharStream);
            }
            else
            {
                memberMap memberMap = value.MemberMap;
                if (memberMap == null || memberMap.IsDefault)
                {
                    fastCSharp.emit.jsonSerializer.typeToJsoner <valueType> .ToJson(toJsoner, value.Value);
                }
                else
                {
                    fastCSharp.emit.jsonSerializer.config config = typePool <fastCSharp.emit.jsonSerializer.config> .Pop() ?? new fastCSharp.emit.jsonSerializer.config(), oldConfig = toJsoner.Config;

                    fastCSharp.emit.memberCopyer <fastCSharp.emit.jsonSerializer.config> .Copy(config, oldConfig);

                    (toJsoner.Config = config).MemberMap = memberMap;
                    try
                    {
                        fastCSharp.emit.jsonSerializer.typeToJsoner <valueType> .ToJson(toJsoner, value.Value);
                    }
                    finally
                    {
                        toJsoner.Config  = oldConfig;
                        config.MemberMap = null;
                        typePool <fastCSharp.emit.jsonSerializer.config> .PushNotNull(config);
                    }
                }
            }
        }
예제 #3
0
파일: menu.cs 프로젝트: iLanceS/fastCSharp
 private static void toJson(fastCSharp.emit.jsonSerializer toJsoner, menu value)
 {
     toJsoner.UnsafeWriteFirstName("name");
     toJsoner.UnsafeToJson(value.name);
     if (value.type != menuType.none)
     {
         toJsoner.UnsafeWriteNextName("type");
         toJsoner.UnsafeToJsonNotNull(value.type);
     }
     if (!string.IsNullOrEmpty(value.key))
     {
         toJsoner.UnsafeWriteNextName("key");
         toJsoner.UnsafeToJsonNotNull(value.key);
     }
     if (!string.IsNullOrEmpty(value.url))
     {
         toJsoner.UnsafeWriteNextName("url");
         toJsoner.UnsafeToJsonNotNull(value.url);
     }
     if (!string.IsNullOrEmpty(value.media_id))
     {
         toJsoner.UnsafeWriteNextName("media_id");
         toJsoner.UnsafeToJsonNotNull(value.media_id);
     }
     if (value.sub_button.length() != 0)
     {
         toJsoner.UnsafeWriteNextName("sub_button");
         toJsoner.UnsafeToJsonNotNull(value.sub_button);
     }
     toJsoner.UnsafeCharStream.Write('}');
 }
예제 #4
0
            private static unsafe void toJson(fastCSharp.emit.jsonSerializer toJsoner, cardMessage value)
            {
                if (value.card_ext.signature == null)
                {
                    log.Default.Add("卡券扩展 签名为空", new System.Diagnostics.StackFrame(), true);
                    fastCSharp.web.ajax.WriteObject(toJsoner.UnsafeCharStream);
                }
                else
                {
                    toJsoner.UnsafeWriteFirstName("card_id");
                    toJsoner.UnsafeToJson(value.card_id);
                    toJsoner.UnsafeWriteNextName("card_ext");
                    fastCSharp.emit.jsonSerializer cardToJsoner = typePool <fastCSharp.emit.jsonSerializer> .Pop() ?? new fastCSharp.emit.jsonSerializer();

                    pointer buffer = fastCSharp.unmanagedPool.StreamBuffers.Get();
                    try
                    {
                        using (charStream cardJsonStream = cardToJsoner.UnsafeCharStream)
                        {
                            cardJsonStream.UnsafeReset((byte *)buffer.Char, fastCSharp.unmanagedPool.StreamBuffers.Size);
                            cardToJsoner.UnsafeToJsonNotNull(value.card_ext, toJsoner.UnsafeConfig);
                            fastCSharp.web.ajax.UnsafeFormatJavascript(cardJsonStream, toJsoner.UnsafeCharStream);
                        }
                    }
                    finally
                    {
                        fastCSharp.unmanagedPool.StreamBuffers.Push(ref buffer);
                        toJsoner.UnsafeFree();
                    }
                    toJsoner.UnsafeCharStream.Write('}');
                }
            }
예제 #5
0
        private static void toJson(fastCSharp.emit.jsonSerializer toJsoner, message value)
        {
            toJsoner.UnsafeWriteFirstName("touser");
            toJsoner.UnsafeToJson(value.touser);
            toJsoner.UnsafeWriteNextName("msgtype");
            toJsoner.UnsafeToJsonNotNull(value.msgtype.ToString());
            toJsoner.UnsafeWriteNextName(value.msgtype.ToString());
            switch (value.msgtype)
            {
            case type.news:
                toJsoner.UnsafeToJsonNotNull(value.news);
                break;

            case type.text:
                toJsoner.UnsafeToJsonNotNull(value.text);
                break;

            case type.image:
                toJsoner.UnsafeToJsonNotNull(value.image);
                break;

            case type.voice:
                toJsoner.UnsafeToJsonNotNull(value.voice);
                break;

            case type.video:
                toJsoner.UnsafeToJsonNotNull(value.video);
                break;

            case type.music:
                toJsoner.UnsafeToJsonNotNull(value.music);
                break;

            case type.wxcard:
                toJsoner.UnsafeToJsonNotNull(value.wxcard);
                break;
            }
            if (value.customservice.kf_account != null)
            {
                toJsoner.UnsafeWriteNextName("customservice");
                toJsoner.UnsafeToJsonNotNull(value.customservice);
            }
            toJsoner.UnsafeCharStream.Write('}');
        }
예제 #6
0
        private static void toJson(fastCSharp.emit.jsonSerializer toJsoner, previewMessage value)
        {
            if (string.IsNullOrEmpty(value.towxname))
            {
                toJsoner.UnsafeWriteFirstName("touser");
                toJsoner.UnsafeToJson(value.touser);
            }
            else
            {
                toJsoner.UnsafeWriteFirstName("towxname");
                toJsoner.UnsafeToJson(value.towxname);
            }
            toJsoner.UnsafeWriteNextName("msgtype");
            toJsoner.UnsafeToJsonNotNull(value.msgtype.ToString());
            toJsoner.UnsafeWriteNextName(value.msgtype.ToString());
            switch (value.msgtype)
            {
            case bulkMessageBase.type.text:
                toJsoner.UnsafeToJsonNotNull(value.text);
                break;

            case bulkMessageBase.type.image:
                toJsoner.UnsafeToJsonNotNull(value.image);
                break;

            case bulkMessageBase.type.voice:
                toJsoner.UnsafeToJsonNotNull(value.voice);
                break;

            case bulkMessageBase.type.mpvideo:
                toJsoner.UnsafeToJsonNotNull(value.mpvideo);
                break;

            case bulkMessageBase.type.mpnews:
                toJsoner.UnsafeToJsonNotNull(value.mpnews);
                break;

            case bulkMessageBase.type.wxcard:
                toJsoner.UnsafeToJsonNotNull(value.wxcard);
                break;
            }
            toJsoner.UnsafeCharStream.Write('}');
        }
예제 #7
0
 private static void toJson(fastCSharp.emit.jsonSerializer toJsoner, deSerializePool value)
 {
     memberMapValue <memberMapType> .ToJson(toJsoner, new memberMapValue <memberMapType> {
         MemberMap = value.MemberMap, Value = value.Value
     });
 }
예제 #8
0
 private static void toJson(fastCSharp.emit.jsonSerializer toJsoner, bulkMessage value)
 {
     toJsoner.UnsafeWriteFirstName("filter");
     toJsoner.UnsafeToJson(value.filter);
     value.toJson(toJsoner);
 }