コード例 #1
0
ファイル: TCGTagHandlers.cs プロジェクト: wangscript/tcgcms
        public bool Replace()
        {
            if (!this._start)
            {
                this._temphtml = this._template;
                this._start = true;
            }
            this.SysteConfigReplace();
            MatchCollection mc = Regex.Matches(this._temphtml, this._pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            if (mc.Count > 0)
            {
                this._tagtemplates = new List<TCGTagAttributeHandlers>();
                foreach (Match item in mc)
                {
                    this._tagtemplate = new TCGTagAttributeHandlers(base.handlerService);
                    this._tagtemplate.configService = base.configService;
                    this._tagtemplate.conn = base.conn;

                    this._tagtemplate.Attribute = item.Result("$2");
                    this._tagtemplate.Tag = string.Format(this._tcgsystemtag, this._index);
                    this._tagtemplate.TagText = item.Result("$3");
                    this._tagtemplate.TagType = item.Result("$1");
                    this._tagtemplate.TagHtml = item.Value;

                    this._temphtml = this._temphtml.Replace(item.Value, this._tagtemplate.Tag);
                    this._tagtemplates.Add(this._tagtemplate);
                    this._tagtemplate = null;
                    this._index++;
                }

                for (int i = 0; i < this._tagtemplates.Count; i++)
                {
                    this._tagtemplates[i].ReplaceTagText(ref this._pagerinfo);
                    if (this._tagtemplates[i].Pager)
                    {
                        this._listtemp = null;
                        this._listtemp = this._tagtemplates[i];
                    }
                    else
                    {
                        this._temphtml = this._tagtemplates[i].Replace(this._temphtml);
                    }
                }

                this._tagtemplates = null;
            }
            else
            {
                if (!this._pagerinfo.Read) return this._pagerinfo.Read;

                if (this._pagerinfo.NeedPager && this._pagerinfo.DoAllPage &&this._pagerinfo.PageSep != 0)
                {
                    Match item = Regex.Match(this._listtemp.TagHtml, this._pattern,RegexOptions.IgnoreCase | RegexOptions.Multiline);
                    if (item.Success)
                    {
                        this._tagtemplate = new TCGTagAttributeHandlers(base.handlerService);
                        this._tagtemplate.configService = base.configService;
                        this._tagtemplate.conn = base.conn;

                        this._tagtemplate.Attribute = item.Result("$2");
                        this._tagtemplate.Tag = string.Format(this._tcgsystemtag, this._index);
                        this._tagtemplate.TagText = item.Result("$3");
                        this._tagtemplate.TagType = item.Result("$1");
                        this._tagtemplate.TagHtml = item.Value;

                        this._tagtemplate.ReplaceTagText(ref this._pagerinfo);
                        this._listtemp.TagText = this._tagtemplate.TagText;
                        this._temphtml = this._template;
                        this._tagtemplate = null;
                    }
                }

                if (this._listtemp != null)
                {
                    if (this._pagerinfo.NeedPager)
                    {
                        if (this._pagerinfo.Page == 1 || !this._pagerinfo.DoAllPage)
                        {
                            this._template = this._temphtml;
                        }
                    }
                    this._temphtml = this._listtemp.Replace(this._temphtml);
                    this.GetPager();
                }
                this._start = false;
                this.Save();
                if (this._pagerinfo.NeedPager&&this._pagerinfo.DoAllPage)
                {

                    if (this._pagerinfo.PageSep == 0)
                    {
                        this._pagerinfo.PageSep = 1;
                    }
                    else
                    {
                        this._pagerinfo.Page++;
                    }
                    if (this._pagerinfo.Page <= this._pagerinfo.PageCount && this._pagerinfo.PageCount != 0)
                    {
                        this.Replace();
                    }
                }
                return this._pagerinfo.Read;
            }

            if (!this._pagerinfo.Read) return this._pagerinfo.Read;
            mc = null;
            return this.Replace();
        }
コード例 #2
0
ファイル: TCGTagHandlers.cs プロジェクト: wangscript/tcgcms
        public bool Replace()
        {
            if (!this._start)
            {
                this._temphtml = this._template;
                this._start = true;
            }
            this.SysteConfigReplace();
            MatchCollection mc = Regex.Matches(this._temphtml, this._pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            if (mc.Count > 0)
            {
                this._tagtemplates = new List<TCGTagAttributeHandlers>();
                foreach (Match item in mc)
                {
                    this._tagtemplate = new TCGTagAttributeHandlers(base.handlerService);

                    this._tagtemplate.Attribute = item.Result("$2");
                    this._tagtemplate.Tag = string.Format(this._tcgsystemtag, this._index);
                    this._tagtemplate.TagText = item.Result("$3");
                    this._tagtemplate.TagType = item.Result("$1");
                    this._tagtemplate.TagHtml = item.Value;

                    this._temphtml = this._temphtml.Replace(item.Value, this._tagtemplate.Tag);
                    this._tagtemplates.Add(this._tagtemplate);
                    this._tagtemplate = null;
                    this._index++;
                }

                for (int i = 0; i < this._tagtemplates.Count; i++)
                {
                    this._tagtemplates[i].ReplaceTagText(ref this._pagerinfo);
                    this._temphtml = this._tagtemplates[i].Replace(this._temphtml);
                }

                this._tagtemplates = null;

                return this.Replace();
            }
            else
            {
                this.Save();
                return this._pagerinfo.Read;
            }
        }