Exemplo n.º 1
0
            /// <summary>
            /// 获取实现 IHtmlContext 接口的 GetContext 方法的内容。
            /// </summary>
            /// <param name="typeName">类型名称</param>
            /// <param name="parameter">参数</param>
            /// <param name="callback">HTML 页面中回调方法的名称</param>
            public void GetHtmlContext(string typeName, string parameter, string callback)
            {
                Type typ = Function.GetType(typeName);

                if (typ != null)
                {
                    try
                    {
                        System.Reflection.ConstructorInfo ciObject = typ.GetConstructor(new System.Type[] { });
                        object obj = ciObject.Invoke(new object[] { });

                        IHtmlContext _IHtmlContext = obj as IHtmlContext;
                        if (_IHtmlContext is IUseAccount)
                        {
                            IUseAccount _IUseAccount = _IHtmlContext as IUseAccount;
                            _IUseAccount.SetAccount(this.PluginView.Application.CurrentAccount);
                        }
                        this.PluginView.SetHtmlContext(callback, true, _IHtmlContext.GetContext(this.PluginView.Application, parameter));
                    }
                    catch (Exception ex)
                    {
                        this.PluginView.SetHtmlContext(callback, false, ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("无法加载名称为“" + typeName + "”的类型", "获取内容", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
Exemplo n.º 2
0
        public virtual string RenderPartial(string pageName, object model, bool renderHtml, StreamWriter writer, IHtmlContext htmlHelper)
        {
            var httpReq     = htmlHelper.HttpRequest;
            var _htmlHelper = (HtmlHelper)htmlHelper;
            var razorPage   = viewManager.GetPartialPage(httpReq, pageName);

            if (razorPage != null)
            {
                using (var page = CreateRazorPageInstance(httpReq, _htmlHelper.HttpResponse, model, razorPage))
                {
                    page.ParentPage = _htmlHelper.RazorPage;
                    page.WriteTo(writer);
                }
            }
            else
            {
                if (RenderPartialFn != null)
                {
                    RenderPartialFn(pageName, model, renderHtml, writer, _htmlHelper, httpReq);
                }
                else
                {
                    writer.Write("<!--No RenderPartialFn, skipping {0}-->".Fmt(pageName));
                }
            }
            return(null);
        }
Exemplo n.º 3
0
        public string RenderPartial(string pageName, object model, bool renderHtml, StreamWriter writer, IHtmlContext htmlHelper = null)
        {
            var markdownPage = ReloadIfNeeded(GetViewPage(pageName, htmlHelper.GetHttpRequest()));
            var output       = RenderDynamicPage(markdownPage, pageName, model, renderHtml, false);

            if (writer != null)
            {
                writer.Write(output);
                writer.Flush();
                return(null);
            }
            return(output);
        }
Exemplo n.º 4
0
 public static IRequest GetHttpRequest(this IHtmlContext html)
 {
     return(html?.HttpRequest);
 }
Exemplo n.º 5
0
 public static IRequest GetHttpRequest(this IHtmlContext html)
 {
     return(html != null ? html.HttpRequest : null);
 }