Ejemplo n.º 1
0
        public static void WriteJsonP(string result)
        {
            string callback = ConvertObject.ToString(HttpContext.Current.Request.Params["callback"]);
            string re_value = callback + "({result:" + result + "})";

            HttpContext.Current.Response.Write(re_value);
            HttpContext.Current.Response.End();
        }
Ejemplo n.º 2
0
        public static string ClassToJson <T>(T t)
        {
            string result = "";
            Type   type   = typeof(T);

            foreach (System.Reflection.PropertyInfo info in type.GetProperties())
            {
                if (info.PropertyType.IsValueType || info.PropertyType.Name.StartsWith("String"))
                {
                    result += info.Name + ":\"" + ConvertObject.ToString(info.GetValue(t, null)) + "\",";
                }
            }
            result = DelComma_AddBracket(result);
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 判断两个对象是否相等
        /// </summary>
        /// <param name="value1"></param>
        /// <param name="value2"></param>
        /// <returns></returns>
        public static bool IsEqual(object value1, object value2)
        {
            bool res = false;

            if (ConvertObject.ToDecimal(value1) > 0 && ConvertObject.ToDecimal(value2) > 0)
            {
                if (ConvertObject.ToDecimal(value1) == ConvertObject.ToDecimal(value2))
                {
                    res = true;
                }
            }
            else if (ConvertObject.ToString(value1).Length > 0 && ConvertObject.ToString(value2).Length > 0)
            {
                if (ConvertObject.ToString(value1).Equals(ConvertObject.ToString(value2)))
                {
                    res = true;
                }
            }
            return(res);
        }