コード例 #1
0
        /// <summary>
        /// 转换为标准数据
        /// </summary>
        /// <param name="sourceData">原始数据</param>
        /// <returns></returns>
        public static NotificationData ToStandardData(NotificationData sourceData)
        {
            var data = new NotificationData();

            data.TrySetData("title", sourceData.TryGetData("title"));
            data.TrySetData("message", sourceData.TryGetData("message"));
            data.TrySetData("description", sourceData.TryGetData("description"));
            data.TrySetData("formUser", sourceData.TryGetData("formUser"));
            data.TrySetData("createTime", sourceData.TryGetData("createTime"));
            data.TrySetData(LocalizerKey, sourceData.TryGetData(LocalizerKey));
            return(data);
        }
コード例 #2
0
        public static NotificationData Convert(NotificationData notificationData)
        {
            if (notificationData != null)
            {
                if (notificationData.NeedLocalizer())
                {
                    var title   = JsonConvert.DeserializeObject <LocalizableStringInfo>(notificationData.TryGetData("title").ToString());
                    var message = JsonConvert.DeserializeObject <LocalizableStringInfo>(notificationData.TryGetData("message").ToString());
                    notificationData.TrySetData("title", title);
                    notificationData.TrySetData("message", message);

                    if (notificationData.Properties.TryGetValue("description", out object description) && description != null)
                    {
                        notificationData.TrySetData("description", JsonConvert.DeserializeObject <LocalizableStringInfo>(description.ToString()));
                    }
                }
            }
            else
            {
                notificationData = new NotificationData();
            }
            return(notificationData);
        }