Ejemplo n.º 1
0
        ///<summary>
        /// Run validation
        ///</summary>
        ///<returns></returns>
        public bool Validate()
        {
            _Errors      = new StringBuilder();
            _CurrentList = new ErrorsCollection();
            foreach (var i in Course.Organization.Items)
            {
                if (i.PageType == PageType.Question)
                {
                    var p = HtmlPageBase.GetPage(i);
                    if (p == null)
                    {
                        using (var page = new HtmlPage {
                            Parent = new Form()
                        })
                        {
                            page.Name = i.Title;
                            page.SetPageItem(i);
                            page.ParseHtmlFile(i.PageHref, (htmlPage, control) => { });
                            page.ReValidate();
                            _CurrentList.AddRange(page.Errors);
                        }
                    }
                    else
                    {
                        p.ReValidate();
                        _CurrentList.AddRange(p.Errors);
                    }

                    foreach (var error in _CurrentList)
                    {
                        if (_Errors.Length > 0)
                        {
                            _Errors.AppendLine();
                        }
                        _Errors.Append(i.GetFullPath());
                        if (error.Source != i)
                        {
                            _Errors.Append("/" + error.Source.Title);
                        }
                        _Errors.Append(": ");
                        _Errors.Append(error.Message);
                    }
                }

                foreach (string error in i.Errors)
                {
                    this._Errors.AppendLine(error);
                }
            }
            return(_Errors.Length == 0);
        }
Ejemplo n.º 2
0
        ///<summary>
        /// Run validation
        ///</summary>
        ///<returns></returns>
        public bool Validate()
        {
            _Errors = new StringBuilder();
            _CurrentList = new ErrorsCollection();
            foreach (var i in Course.Organization.Items)
            {
                if (i.PageType == PageType.Question)
                {
                    var p = HtmlPageBase.GetPage(i);
                    if (p == null)
                    {
                        using (var page = new HtmlPage { Parent = new Form() })
                        {
                            page.Name = i.Title;
                            page.SetPageItem(i);
                            page.ParseHtmlFile(i.PageHref, (htmlPage, control) => { });
                            page.ReValidate();
                            _CurrentList.AddRange(page.Errors);
                        }
                    }
                    else
                    {
                        p.ReValidate();
                        _CurrentList.AddRange(p.Errors);
                    }

                    foreach (var error in _CurrentList)
                    {
                        if (_Errors.Length > 0)
                        {
                            _Errors.AppendLine();
                        }
                        _Errors.Append(i.GetFullPath());
                        if (error.Source != i)
                        {
                            _Errors.Append("/" + error.Source.Title);
                        }
                        _Errors.Append(": ");
                        _Errors.Append(error.Message);
                    }
                }

                foreach (string error in i.Errors)
                {
                    this._Errors.AppendLine(error);
                }
            }
            return _Errors.Length == 0;
        }