示例#1
0
        public object Render(RenderContext context)
        {
            var engine = Scripting.Manager.GetJsEngine(context);

            var prog = engine.GetValue(FunctionName);

            if (prog != null && prog != Jint.Native.JsValue.Undefined)
            {
                var paras = FunctionHelper.RenderParameter(context, this.Parameters);

                var result = engine.Invoke(prog, paras.ToArray());

                if (result != null)
                {
                    return(result.ToString());
                }
            }
            return(null);
        }
示例#2
0
        public object Render(RenderContext context)
        {
            var paras = FunctionHelper.RenderParameter(context, this.Parameters);

            if (paras != null && paras.Count() > 0)
            {
                var value = paras[0];
                if (value != null)
                {
                    if (value is ICollection)
                    {
                        var col = (ICollection)value;
                        if (col != null)
                        {
                            return(col.Count);
                        }
                    }
                    else if (value is string)
                    {
                        try
                        {
                            var jarray = Lib.Helper.JsonHelper.DeserialzeBaseObject(value.ToString());
                            if (jarray != null && jarray is JArray)
                            {
                                var jr = jarray as JArray;
                                if (jr != null)
                                {
                                    return(jr.Count);
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            return(0);
        }
示例#3
0
        public object Render(RenderContext context)
        {
            string relative = context.Request.RelativeUrl;

            if (relative.IndexOf("?") > -1)
            {
                relative = relative.Substring(0, relative.IndexOf("?"));
            }

            var paras = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (var item in context.Request.QueryString.AllKeys)
            {
                var value = context.Request.QueryString[item];

                if (!paras.ContainsKey(item))
                {
                    paras.Add(item, value);
                }
            }

            var providedParas = FunctionHelper.RenderParameter(context, this.Parameters);

            var dict = ToDictionary(providedParas);

            foreach (var item in dict)
            {
                paras[item.Key] = item.Value;
            }
            if (paras.Count() > 0)
            {
                return(Lib.Helper.UrlHelper.AppendQueryString(relative, paras));
            }
            else
            {
                return(relative);
            }
        }