Ejemplo n.º 1
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);

            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);
            }
        }
Ejemplo n.º 2
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 && result.IsNull() == false)
                {
                    if (result.IsArray())
                    {
                        var items = result.AsArray();

                        var arrayResult = new List <object>();

                        var ownproperties = items.GetOwnProperties().Where(o => o.Key != "length").ToList();

                        foreach (Jint.Native.JsValue item in ownproperties.Select(p => p.Value.Value))
                        {
                            arrayResult.Add(item);
                        }
                        return(arrayResult);
                    }
                    return(result.ToString());
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        public object Render(RenderContext context)
        {
            var paras = FunctionHelper.RenderParameter(context, this.Parameters);

            if (paras.Any())
            {
                var item = paras[0];
                if (item != null)
                {
                    string fullurl = item.ToString().ToLower();

                    if (fullurl.StartsWith("https://") || fullurl.StartsWith("http://") || fullurl.StartsWith("//"))
                    {
                        var uri = new Uri(fullurl);
                        if (uri.Host != context.Request.Host)
                        {
                            // do the cache.
                            var cacheitem = Kooboo.Sites.Render.LocalCache.LocalCacheManager.SetItem(context.WebSite, fullurl);
                            return(Sites.Render.LocalCache.LocalCacheManager.GetUrl(cacheitem));
                        }
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 4
0
        public object Render(RenderContext context)
        {
            var    paras         = FunctionHelper.RenderParameter(context, this.Parameters);
            string formatestring = paras[1].ToString();
            var    datetiem      = Convert.ToDateTime(paras[0]);

            return(datetiem.ToString(formatestring));
        }
Ejemplo n.º 5
0
        public object Render(RenderContext context)
        {
            var paras = FunctionHelper.RenderParameter(context, this.Parameters);

            string result = string.Empty;

            foreach (var item in paras)
            {
                if (item != null)
                {
                    result += item.ToString();
                }
            }
            return(result);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);

            if (providedParas != null && providedParas.Count() > 0)
            {
                paras["PageNumber"] = providedParas[0].ToString();
            }

            if (paras.Count() > 0)
            {
                return(Lib.Helper.UrlHelper.AppendQueryString(relative, paras));
            }
            else
            {
                return(relative);
            }
        }