Exemple #1
0
        internal void ToJson(AutoCSer.Json.Serializer serializer)
        {
            MemberMap memberMap = MemberMap;

            if (memberMap == null || memberMap.IsDefault)
            {
                serializer.TypeSerialize(Value);
            }
            else
            {
                MemberMapValueJsonSerializeConfig config    = MemberMapValueJsonSerializeConfig.Pop() ?? new MemberMapValueJsonSerializeConfig();
                AutoCSer.Json.SerializeConfig     oldConfig = serializer.Config;
                AutoCSer.MemberCopy.Copyer <AutoCSer.Json.SerializeConfig> .Copy(config, oldConfig);

                (serializer.Config = config).MemberMap = memberMap;
                try
                {
                    serializer.TypeSerialize(Value);
                }
                finally
                {
                    serializer.Config = oldConfig;
                    config.MemberMap  = null;
                    MemberMapValueJsonSerializeConfig.PushNotNull(config);
                }
            }
        }
Exemple #2
0
 private void toJson(AutoCSer.Json.Serializer serializer)
 {
     serializer.CustomWriteFirstName("name");
     serializer.CallSerialize(name);
     if (type != MenuType.none)
     {
         serializer.CustomWriteNextName("type");
         serializer.TypeSerialize(ref type);
     }
     if (!string.IsNullOrEmpty(key))
     {
         serializer.CustomWriteNextName("key");
         serializer.CallSerialize(key);
     }
     if (!string.IsNullOrEmpty(url))
     {
         serializer.CustomWriteNextName("url");
         serializer.CallSerialize(url);
     }
     if (!string.IsNullOrEmpty(media_id))
     {
         serializer.CustomWriteNextName("media_id");
         serializer.CallSerialize(media_id);
     }
     if (sub_button.length() != 0)
     {
         serializer.CustomWriteNextName("sub_button");
         serializer.TypeSerialize(sub_button);
     }
     serializer.CustomObjectEnd();
 }
 internal void ToJson(AutoCSer.Json.Serializer serializer)
 {
     if (MemberMap == null || MemberMap.IsDefault)
     {
         serializer.TypeSerialize(Value);
     }
     else
     {
         AutoCSer.Metadata.MemberMap memberMap = serializer.SetCustomMemberMap(MemberMap);
         try
         {
             serializer.TypeSerialize(Value);
         }
         finally { serializer.SetCustomMemberMap(memberMap); }
     }
 }
        /// <summary>
        /// 对象序列化
        /// </summary>
        /// <param name="serializer"></param>
        protected void toJson(AutoCSer.Json.Serializer serializer)
        {
            serializer.CustomWriteNextName("msgtype");
            serializer.CallSerialize(msgtype.ToString());
            serializer.CustomWriteNextName(msgtype.ToString());
            switch (msgtype)
            {
            case BulkMessageType.mpnews:
                serializer.TypeSerialize(ref mpnews);
                break;

            case BulkMessageType.text:
                serializer.TypeSerialize(ref text);
                break;

            case BulkMessageType.image:
                serializer.TypeSerialize(ref image);
                break;

            case BulkMessageType.voice:
                serializer.TypeSerialize(ref voice);
                break;

            case BulkMessageType.mpvideo:
                serializer.TypeSerialize(ref mpvideo);
                break;

            case BulkMessageType.wxcard:
                serializer.TypeSerialize(ref wxcard);
                break;
            }
            serializer.CustomObjectEnd();
        }
Exemple #5
0
        /// <summary>
        /// 对象序列化
        /// </summary>
        /// <param name="serializer"></param>
        private void toJson(AutoCSer.Json.Serializer serializer)
        {
            serializer.CustomWriteFirstName("touser");
            serializer.CallSerialize(touser);
            serializer.CustomWriteNextName("msgtype");
            serializer.CallSerialize(msgtype.ToString());
            serializer.CustomWriteNextName(msgtype.ToString());
            switch (msgtype)
            {
            case MessageType.news:
                serializer.TypeSerialize(ref news);
                break;

            case MessageType.text:
                serializer.TypeSerialize(ref text);
                break;

            case MessageType.image:
                serializer.TypeSerialize(ref image);
                break;

            case MessageType.voice:
                serializer.TypeSerialize(ref voice);
                break;

            case MessageType.video:
                serializer.TypeSerialize(ref video);
                break;

            case MessageType.music:
                serializer.TypeSerialize(ref music);
                break;

            case MessageType.wxcard:
                serializer.TypeSerialize(ref wxcard);
                break;
            }
            if (customservice.kf_account != null)
            {
                serializer.CustomWriteNextName("customservice");
                serializer.TypeSerialize(ref customservice);
            }
            serializer.CustomObjectEnd();
        }
Exemple #6
0
 private void toJson(AutoCSer.Json.Serializer serializer)
 {
     serializer.CustomWriteFirstName("action_name");
     if (expire_seconds == 0)
     {
         serializer.CallSerialize(action_info.scene.scene_str == null ? "QR_LIMIT_SCENE" : "QR_LIMIT_STR_SCENE");
     }
     else
     {
         serializer.CallSerialize("QR_SCENE");
         serializer.CustomWriteNextName("expire_seconds");
         serializer.CallSerialize(expire_seconds);
     }
     serializer.CustomWriteNextName("action_info");
     serializer.TypeSerialize(ref action_info);
     serializer.CustomObjectEnd();
 }
        /// <summary>
        /// 对象序列化
        /// </summary>
        /// <param name="serializer"></param>
        private void toJson(AutoCSer.Json.Serializer serializer)
        {
            if (string.IsNullOrEmpty(towxname))
            {
                serializer.CustomWriteFirstName("touser");
                serializer.CallSerialize(touser);
            }
            else
            {
                serializer.CustomWriteFirstName("towxname");
                serializer.CallSerialize(towxname);
            }
            serializer.CustomWriteNextName("msgtype");
            serializer.CallSerialize(msgtype.ToString());
            serializer.CustomWriteNextName(msgtype.ToString());
            switch (msgtype)
            {
            case BulkMessageType.text:
                serializer.TypeSerialize(ref text);
                break;

            case BulkMessageType.image:
                serializer.TypeSerialize(ref image);
                break;

            case BulkMessageType.voice:
                serializer.TypeSerialize(ref voice);
                break;

            case BulkMessageType.mpvideo:
                serializer.TypeSerialize(ref mpvideo);
                break;

            case BulkMessageType.mpnews:
                serializer.TypeSerialize(ref mpnews);
                break;

            case BulkMessageType.wxcard:
                serializer.TypeSerialize(ref wxcard);
                break;
            }
            serializer.CustomObjectEnd();
        }
 private static void toJson(AutoCSer.Json.Serializer serializer, OpenIdMessage value)
 {
     serializer.CustomWriteFirstName("touser");
     serializer.TypeSerialize(value.touser);
     value.toJson(serializer);
 }
Exemple #9
0
 internal void Serialize(AutoCSer.Json.Serializer serializer)
 {
     serializer.TypeSerialize(Value == null ? 1 : 2);
 }
Exemple #10
0
 public void GetMessage()
 {
     jsonStream.Clear();
     jsonSerializer.TypeSerialize(message);
     RepsonseEnd(jsonStream);
 }
 private static void toJson(AutoCSer.Json.Serializer serializer, BulkMessage value)
 {
     serializer.CustomWriteFirstName("filter");
     serializer.TypeSerialize(ref value.filter);
     value.toJson(serializer);
 }