Esempio n. 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);
                }
            }
        }
Esempio n. 2
0
        /// <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();
        }
Esempio n. 3
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();
 }
Esempio n. 4
0
 private void serialize(AutoCSer.Json.Serializer serializer)
 {
     serializer.CharStream.Write('[');
     serializer.Serialize(ClientNodeId);
     serializer.CharStream.Write(',');
     Node.Serialize(serializer, Checker);
     serializer.CharStream.Write(']');
 }
Esempio n. 5
0
 protected void serializeParent(AutoCSer.Json.Serializer serializer, ServerNodeIdChecker checker)
 {
     if (Parent != null)
     {
         serializer.CharStream.Write(',');
         Parent.Serialize(serializer, checker);
     }
     serializer.CharStream.Write(']');
 }
Esempio n. 6
0
 protected void serializeParameter <parameterType>(AutoCSer.Json.Serializer serializer, parameterType parameter)
 {
     if (parameter == null)
     {
         serializer.CharStream.WriteJsonNull();
     }
     else
     {
         AutoCSer.Json.TypeSerializer <parameterType> .Serialize(serializer, ref parameter);
     }
 }
 protected override void serializeParameter(AutoCSer.Json.Serializer serializer)
 {
     #region LOOP IntputParameters
     #region IF ParameterType.IsNull
     base.serializeParameter(serializer, @ParameterName);
     #endregion IF ParameterType.IsNull
     #region NOT ParameterType.IsNull
     base.serializeParameterStruct(serializer, ref @ParameterName);
     #endregion NOT ParameterType.IsNull
     #endregion LOOP IntputParameters
 }
Esempio n. 8
0
 protected override void serialize(AutoCSer.Json.Serializer serializer, AutoCSer.Net.RemoteExpression.ServerNodeIdChecker checker)
 {
     serializeStart(serializer, checker);
     #region LOOP IntputParameters
     #region IF ParameterType.IsNull
     serializeParameter(serializer, @ParameterName);
     #endregion IF ParameterType.IsNull
     #region NOT ParameterType.IsNull
     serializeParameterStruct(serializer, ref @ParameterName);
     #endregion NOT ParameterType.IsNull
     #endregion LOOP IntputParameters
     serializeParent(serializer, checker);
 }
Esempio n. 9
0
 private void toJson(AutoCSer.Json.Serializer serializer)
 {
     if (scene_str == null)
     {
         serializer.CustomWriteFirstName("scene_id");
         serializer.CustomSerialize(scene_id);
     }
     else
     {
         serializer.CustomWriteFirstName("scene_str");
         serializer.CustomSerialize(scene_str);
     }
     serializer.CustomObjectEnd();
 }
Esempio n. 10
0
 private static void serialize(AutoCSer.Json.Serializer serializer, ReturnValue value)
 {
     if (value == null)
     {
         serializer.CharStream.WriteJsonArray();
     }
     else
     {
         CharStream jsonStream = serializer.CharStream;
         jsonStream.Write('[');
         serializer.Serialize(value.ClientNodeId);
         jsonStream.Write(',');
         value.serialize(serializer);
         jsonStream.Write(']');
     }
 }
Esempio n. 11
0
 private unsafe void toJson(AutoCSer.Json.Serializer serializer)
 {
     if (card_ext.signature == null)
     {
         AutoCSer.Log.Pub.Log.Add(Log.LogType.Debug | Log.LogType.Info, "卡券扩展 签名为空");
         serializer.CharStream.WriteJsonObject();
     }
     else
     {
         serializer.CustomWriteFirstName("card_id");
         serializer.CallSerialize(card_id);
         serializer.CustomWriteNextName("card_ext");
         serializer.CallSerialize(AutoCSer.Json.Serializer.Serialize(card_ext));
         serializer.CustomObjectEnd();
     }
 }
Esempio n. 12
0
 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); }
     }
 }
Esempio n. 13
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();
 }
Esempio n. 14
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();
        }
Esempio n. 15
0
        /// <summary>
        /// 对象序列化
        /// </summary>
        /// <param name="serializer"></param>
        private void toJson(AutoCSer.Json.Serializer serializer)
        {
            if (string.IsNullOrEmpty(towxname))
            {
                serializer.CustomWriteFirstName("touser");
                serializer.CustomSerialize(touser);
            }
            else
            {
                serializer.CustomWriteFirstName("towxname");
                serializer.CustomSerialize(towxname);
            }
            serializer.CustomWriteNextName("msgtype");
            serializer.CustomSerialize(msgtype.ToString());
            serializer.CustomWriteNextName(msgtype.ToString());
            switch (msgtype)
            {
            case BulkMessageType.text:
                serializer.CustomSerialize(text);
                break;

            case BulkMessageType.image:
                serializer.CustomSerialize(image);
                break;

            case BulkMessageType.voice:
                serializer.CustomSerialize(voice);
                break;

            case BulkMessageType.mpvideo:
                serializer.CustomSerialize(mpvideo);
                break;

            case BulkMessageType.mpnews:
                serializer.CustomSerialize(mpnews);
                break;

            case BulkMessageType.wxcard:
                serializer.CustomSerialize(wxcard);
                break;
            }
            serializer.CustomObjectEnd();
        }
Esempio n. 16
0
 private void toJson(AutoCSer.Json.Serializer toJsoner)
 {
     new AutoCSer.Metadata.MemberMapValue <memberMapType> {
         MemberMap = MemberMap, Value = Value
     }.ToJson(toJsoner);
 }
Esempio n. 17
0
 protected override void serializeParameter(AutoCSer.Json.Serializer serializer)
 {
     base.serializeParameterStruct(serializer, ref value);
 }
Esempio n. 18
0
 internal static void Serialize(AutoCSer.Json.Serializer serializer, CustomClass value)
 {
     serializer.CharStream.Write(value.Value == null ? '1' : '2');
 }
Esempio n. 19
0
 private static void toJson(AutoCSer.Json.Serializer serializer, PreviewMessage value)
 {
     value.toJson(serializer);
 }
Esempio n. 20
0
 private static void toJson(AutoCSer.Json.Serializer serializer, OpenIdMessage value)
 {
     serializer.CustomWriteFirstName("touser");
     serializer.TypeSerialize(value.touser);
     value.toJson(serializer);
 }
Esempio n. 21
0
 protected void serializeStart(AutoCSer.Json.Serializer serializer, ServerNodeIdChecker checker)
 {
     serializer.CharStream.Write('[');
     serializer.CallSerialize(checker.ServerNodeIds[GetType()]);
 }
Esempio n. 22
0
 /// <summary>
 /// JSON 调用测试
 /// </summary>
 public Json()
 {
     jsonSerializer = AutoCSer.Json.Serializer.CreateDefault(out jsonStream);
 }
Esempio n. 23
0
 internal void Serialize(AutoCSer.Json.Serializer serializer)
 {
     serializer.TypeSerialize(Value == null ? 1 : 2);
 }
Esempio n. 24
0
 protected void serializeParameterStruct <parameterType>(AutoCSer.Json.Serializer serializer, ref parameterType parameter)
 {
     AutoCSer.Json.TypeSerializer <parameterType> .StructSerialize(serializer, ref parameter);
 }
Esempio n. 25
0
 /// <summary>
 /// 服务端序列化返回值
 /// </summary>
 /// <param name="serializer"></param>
 protected virtual void serialize(AutoCSer.Json.Serializer serializer)
 {
 }
Esempio n. 26
0
 /// <summary>
 /// 客户端序列化
 /// </summary>
 /// <param name="serializer"></param>
 protected virtual void serializeParameter(AutoCSer.Json.Serializer serializer)
 {
 }
Esempio n. 27
0
 private static void toJson(AutoCSer.Json.Serializer serializer, BulkMessage value)
 {
     serializer.CustomWriteFirstName("filter");
     serializer.CustomSerialize(value.filter);
     value.toJson(serializer);
 }
Esempio n. 28
0
 protected override void serialize(AutoCSer.Json.Serializer serializer, AutoCSer.Net.RemoteExpression.ServerNodeIdChecker checker)
 {
     serializeStart(serializer, checker);
     serializeParameterStruct(serializer, ref value);
     serializeParent(serializer, checker);
 }
Esempio n. 29
0
 internal void Serialize(AutoCSer.Json.Serializer serializer, ServerNodeIdChecker checker)
 {
     serializeStart(serializer, checker);
     serializeParameter(serializer);
     serializeParent(serializer, checker);
 }