Esempio n. 1
0
 public HostJsView()
 {
     _context                = new HostViewContext();
     _context.RootPath       = GlobalCommon.HostCommon.RootPath;
     _context.RunTimeLibPath = GlobalCommon.HostCommon.RootPath + HostJsConstants.COMPILED_ROOT_PATH;
     _context.CommonLibPath  = GlobalCommon.HostCommon.RootPath;
 }
Esempio n. 2
0
        /// <summary>
        /// 根据指定的上下文结构执行View渲染
        /// </summary>
        /// <param name="js"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public string Render(string js, HostViewContext context)
        {
            var rtn = "";

            try
            {
                var l = context.AllHostJsObject;
                List <KeyValuePair <string, object> > kvp = new List <KeyValuePair <string, object> >();
                foreach (var item in l)
                {
                    if (item.Name.ToLower() != "model")
                    {
                        kvp.Add(new KeyValuePair <string, object>(item.Name, item));
                    }
                }
                kvp.Add(new KeyValuePair <string, object>("model", context.CurrentModel));
                context.CurrentHostJsEngine.Evaluate(js, kvp.ToArray());
                rtn = ((ViewDocument)context.GetHostJsObject("viewdoc")).OutHtml();
            }
            finally
            {
                context.CurrentHostJsEngine.Release();
            }
            return(rtn);
        }
Esempio n. 3
0
 public HostJsView(HostViewContext context)
 {
     _context = context;
 }