Пример #1
0
        public static string SerializeObjectToJsonString(ShareThisObject obj)
        {
            var b = new StringBuilder("{");
            var objectPropertyList = new List <string>();

            if (!string.IsNullOrEmpty(obj.Author))
            {
                objectPropertyList.Add("author: " + UIClientScript.EncodeText(obj.Author));
            }
            if (!string.IsNullOrEmpty(obj.Category))
            {
                objectPropertyList.Add("category: " + UIClientScript.EncodeText(obj.Category));
            }
            if (!string.IsNullOrEmpty(obj.Content))
            {
                objectPropertyList.Add("content: " + UIClientScript.EncodeText(obj.Content));
            }
            if (!string.IsNullOrEmpty(obj.Icon))
            {
                objectPropertyList.Add("icon: " + UIClientScript.EncodeText(obj.Icon));
            }
            if (!string.IsNullOrEmpty(obj.Published))
            {
                objectPropertyList.Add("published: " + UIClientScript.EncodeText(obj.Published));
            }
            if (!string.IsNullOrEmpty(obj.Summary))
            {
                objectPropertyList.Add("summary: " + UIClientScript.EncodeText(obj.Summary));
            }
            if (!string.IsNullOrEmpty(obj.Title))
            {
                objectPropertyList.Add("title: " + UIClientScript.EncodeText(obj.Title));
            }
            if (!string.IsNullOrEmpty(obj.Updated))
            {
                objectPropertyList.Add("updated: " + UIClientScript.EncodeText(obj.Updated));
            }
            if (!string.IsNullOrEmpty(obj.Url))
            {
                objectPropertyList.Add("url: " + UIClientScript.EncodeText(obj.Url));
            }
            //
            b.Append(string.Join(",", objectPropertyList.ToArray()));
            b.Append("}");
            return(b.ToString());
        }
Пример #2
0
        public static string SerializeObjectMetaToJsonString(ShareThisObjectMeta objMeta, bool hasButton)
        {
            var b = new StringBuilder("{");

            b.Append("button: " + (hasButton ? "true" : "false"));
            b.AppendFormat(", embeds: {0}", UIClientScript.EncodeBool(objMeta.Embeds));
            if (objMeta.OffsetLeft != 0)
            {
                b.AppendFormat(", offsetLeft: {0}", UIClientScript.EncodeInt32(objMeta.OffsetLeft));
            }
            if (objMeta.OffsetTop != 0)
            {
                b.AppendFormat(", offsetTop: {0}", UIClientScript.EncodeInt32(objMeta.OffsetTop));
            }
            if (!string.IsNullOrEmpty(objMeta.OnClientClick))
            {
                b.AppendFormat(", onclick: {0}", objMeta.OnClientClick);
            }
            b.AppendFormat(", popup: {0}", UIClientScript.EncodeBool(objMeta.Popup));
            b.Append("}");
            return(b.ToString());
        }