Пример #1
0
        public static JsExpression Value(object value)
        {
            var s = JavaScriptHelper.ToJavaScriptValue(value);

            //if (value is char)
            //    return Code(JavaScriptHelper.ToJavaScriptChar((char)value));
            //else if(value is string)
            //    return Code(JavaScriptHelper.ToJavaScriptString((string)value));
            //var s = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(value);
            return(CodeExpression(s));//JavaScriptHelper.ToJavaScriptValue(value));
        }
Пример #2
0
        public static JsExpression Value(object value, string comment = "")
        {
            var s = JavaScriptHelper.ToJavaScriptValue(value);
            //if (value is char)
            //    return Code(JavaScriptHelper.ToJavaScriptChar((char)value));
            //else if(value is string)
            //    return Code(JavaScriptHelper.ToJavaScriptString((string)value));
            //var s = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(value);
            //return CodeExpression(s);//JavaScriptHelper.ToJavaScriptValue(value));
            var codeExpr = CodeExpression(s);

            if (comment.IsNotNullOrEmpty())
            {
                codeExpr.Code += comment;
            }
            return(codeExpr);
        }