예제 #1
0
        /// <summary>
        /// 引发<see cref="ErrorItemRendering"/>事件。
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnErrorItemRendering(NoticeRenderEventArgs e)
        {
            var handler = (EventHandler <NoticeRenderEventArgs>) this.Events[EventItemRendering];

            if (handler != null)
            {
                handler(this, e);
            }
        }
예제 #2
0
        protected virtual void RenderDetails(HtmlTextWriter writer)
        {
            writer.AddAttribute("data-actrole", "details");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "pc-details");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            if (this.HasErrors)
            {
                NoticeRenderEventArgs e = new NoticeRenderEventArgs(writer);
                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
                writer.RenderBeginTag(HtmlTextWriterTag.Dir);
                string[] env = MCS.Library.Core.EnvironmentHelper.GetEnvironmentInfo().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string line in env)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.P);
                    writer.WriteEncodedText(line);
                    writer.RenderEndTag();
                }

                writer.RenderEndTag();

                writer.RenderBeginTag(HtmlTextWriterTag.Ol);
                foreach (object o in this.Errors)
                {
                    e.Item = o;
                    this.OnErrorItemRendering(e);                     // 允许对呈现进行控制
                    if (e.PreventDefault == false)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, "pc-item");
                        writer.RenderBeginTag(HtmlTextWriterTag.Li);
                        if (o is string)
                        {
                            this.RenderStringItem(o as string, writer);
                        }
                        else if (o is Exception)
                        {
                            this.RenderErrorItem(o as Exception, writer);
                        }
                        else
                        {
                            this.RenderObjectItem(o, writer);
                        }

                        writer.RenderEndTag();
                    }
                    else
                    {
                        e.PreventDefault = false;
                    }
                }

                writer.RenderEndTag();
            }

            writer.RenderEndTag();
        }