Exemple #1
0
        public static RenderRespnose RenderHtml(RenderContext Context, RenderOption option, string relativeurl)
        {
            var sourceprovider = GetSourceProvider(Context, option);

            RenderRespnose response = new RenderRespnose();

            response.ContentType = "text/html";
            string minetype = IOHelper.MimeType(relativeurl);

            if (!string.IsNullOrEmpty(minetype))
            {
                response.ContentType = minetype;
            }

            if (Context == null || sourceprovider == null)
            {
                return(response);
            }
            string htmlbody = sourceprovider.GetString(Context, relativeurl);

            if (string.IsNullOrEmpty(htmlbody))
            {
                return(response);
            }

            var hashid = Lib.Security.Hash.ComputeHashGuid(htmlbody);

            var EvaluatorOption = new EvaluatorOption();

            EvaluatorOption.EnableImageBrowserCache = true;
            EvaluatorOption.EnableJsCssBrowserCache = true;

            EvaluatorOption.Evaluators = Kooboo.Render.Components.EvaluatorContainer.ListWithServerComponent;

            var RenderPlan = RenderPlanCache.GetOrAddRenderPlan(hashid, () => RenderEvaluator.Evaluate(htmlbody, EvaluatorOption));

            // set the culture...
            string culture = Context.Culture;

            if (!string.IsNullOrEmpty(culture))
            {
                Context.DataContext.Push("culture", culture);
            }

            string result = Kooboo.Sites.Render.RenderHelper.Render(RenderPlan, Context);

            string finalreseult = null;

            if (!string.IsNullOrEmpty(finalreseult))
            {
                response.Body = finalreseult;
            }
            else
            {
                response.Body = result;
            }

            return(response);
        }
Exemple #2
0
        public static RenderRespnose RenderHtml(RenderContext Context, RenderOption option, string relativeurl)
        {
            var sourceprovider = GetSourceProvider(Context, option);

            RenderRespnose response = new RenderRespnose();

            response.ContentType = "text/html";
            string minetype = IOHelper.MimeType(relativeurl);

            if (!string.IsNullOrEmpty(minetype))
            {
                response.ContentType = minetype;
            }

            if (Context == null || sourceprovider == null)
            {
                return(response);
            }
            string htmlbody = sourceprovider.GetString(Context, relativeurl);

            if (string.IsNullOrEmpty(htmlbody))
            {
                return(response);
            }

            var hashid = Lib.Security.Hash.ComputeHashGuid(htmlbody);

            var RenderPlan = RenderPlanCache.GetOrAddRenderPlan(hashid, () => RenderEvaluator.Evaluate(htmlbody, new EvaluatorOption()));

            string result = Kooboo.Sites.Render.RenderHelper.Render(RenderPlan, Context);

            string finalreseult = null;

            if (!string.IsNullOrEmpty(finalreseult))
            {
                response.Body = finalreseult;
            }
            else
            {
                response.Body = result;
            }

            return(response);
        }