示例#1
0
        public static Constant include(Constant _this, Constant[] arguments, Scope scope)
        {
            var name = Core.Tool.GetArgument <Core.Javascript.String>(arguments, 0, "XDoc.include");

            var context = HttpContext.Current;

            XHTMLMerge.AppCache appCache = null;
            XHTMLMerge.SVCache  svCache  = null;

            if (context != null && context.Application != null)
            {
                appCache = (XHTMLMerge.AppCache)context.Application["AppCache"];
            }
            if (appCache == null)
            {
                appCache = new XHTMLMerge.AppCache();
            }

            if (context != null && context.Session != null)
            {
                svCache = (XHTMLMerge.SVCache)context.Session["SVCache"];
            }
            if (svCache == null)
            {
                svCache = new XHTMLMerge.SVCache();
            }

            var parameters = new Hashtable();

            if (arguments.Length > 1)
            {
                var param = (Core.Javascript.Object)arguments[1];
                foreach (var key in param.GetKeys())
                {
                    parameters.Add(key, param.Get(key).ToString());
                }
            }

            var application = Tool.GetFromScope <JSApplication>(scope, "__application__");

            if (application == null)
            {
                throw new InternalError("No application");
            }
            var result = application.XDocService.RunTemplate(context, name.Value, parameters, ref appCache, ref svCache);

            if (context != null && context.Application != null)
            {
                context.Application["AppCache"] = appCache;
            }
            if (context != null && context.Session != null)
            {
                context.Session["SVCache"] = svCache;
            }

            return(new Core.Javascript.String(result));
        }
示例#2
0
        public static XDocInfo GetXDocInfo()
        {
            var context = HttpContext.Current;

            XHTMLMerge.AppCache appCache = null;
            XHTMLMerge.SVCache  svCache  = null;

            if (context != null)
            {
                if (context.Application != null)
                {
                    appCache = (XHTMLMerge.AppCache)context.Application["AppCache"];
                }
                if (context.Session != null)
                {
                    svCache = (XHTMLMerge.SVCache)context.Session["SVCache"];
                }
            }
            else
            {
                var application = State.Application;
                var session     = State.Session;

                if (application.Get("AppCache") is object af)
                {
                    appCache = (XHTMLMerge.AppCache)af;
                }
                if (session.Get("SVCache") is object sf)
                {
                    svCache = (XHTMLMerge.SVCache)sf;
                }
            }

            if (appCache == null)
            {
                appCache = new XHTMLMerge.AppCache();
            }
            if (svCache == null)
            {
                svCache = new XHTMLMerge.SVCache();
            }

            return(new XDocInfo()
            {
                AppCache = appCache, SVCache = svCache
            });
        }