Beispiel #1
0
        internal static void FilledInTagList(string tagdef, ArrayList tagList, IResourceDependency res)
        {
            int idxBegin = 0, idxEnd = 0;
            idxBegin = tagdef.IndexOf("#}");
            idxEnd = tagdef.LastIndexOf("{#");
            tagdef = tagdef.Substring(idxBegin+2, idxEnd - idxBegin-2).Trim();

            Regex regEx = new Regex(TagBase.TagDefinitionPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            idxBegin = idxEnd = 0;
            MatchCollection mc = regEx.Matches(tagdef, idxBegin);
            HtmlTextTag htmlTag = null;
            while (mc.Count > 0)
            {
                Match m = mc[0];
                idxEnd = m.Index;

                if (idxEnd > idxBegin)
                {
                    htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin, idxEnd - idxBegin));
                    tagList.Add(htmlTag);
                }

                TagBase tag = new TagBase(m.Value, m.Index, ref tagdef);
                //Util.Debug(tag.Category);
                if (tag.Category == TagCategory.AutoTag)
                {
                    AutoItem item = AutoItem.Parse(tag);
                    if (res.GetType() == typeof(PagerTag))
                    {
                        item.CallerTag = (PagerTag)res;
                    }
                    tagList.Add(item);
                }
                else if (tag.Category == TagCategory.DefineTag)
                {
                    //数据库标签定义格式为 {#%FieldName%#}
                    if (res != null)
                    {
                        htmlTag = new HtmlTextTag(res.GetDefinition(tag.OuterDefineText).ToString());
                        tagList.Add(htmlTag);
                    }
                }
                else if (tag.Category == TagCategory.CustomTag)
                {
                    #region 数据定义标签内包含数据定义标签
                    DbStoredCustomTag dbTag = DbStoredCustomTag.Parse(tag);
                    dbTag.SetResourceDependency(res);
                    if (dbTag.IsExist == true)
                    {
                        htmlTag = new HtmlTextTag(dbTag.GetTagValue().ToString());
                        tagList.Add(htmlTag);
                    }
                    #endregion
                }
                else if (tag.Category == TagCategory.SystemTag)
                {
                    string pageURLKey = ",FirstUrl,PreUrl,NextUrl,LastUrl,CurUrl,";
                    string tagName = tag.TagName.Trim('$');
                    if (pageURLKey.IndexOf("," + tagName + ",", StringComparison.InvariantCultureIgnoreCase) != -1)
                    {
                        tagName = tagName.ToLower();
                        PageUrl url = new PageUrl(tag.OuterDefineText);
                        url.IsAutoItem = (res != null && res.GetType() == typeof(AutoItem));
                        url.SetResourceDependency(res);
                        switch (tagName)
                        {
                            case "firsturl": url.UrlCategory = PageUrlCategory.FirstPage; break;
                            case "preurl": url.UrlCategory = PageUrlCategory.PrePage; break;
                            case "nexturl": url.UrlCategory = PageUrlCategory.NextPage; break;
                            case "lasturl": url.UrlCategory = PageUrlCategory.LastPage; break;
                            case "cururl": url.UrlCategory = PageUrlCategory.ThisPage; break;
                            default:
                                url.UrlCategory = PageUrlCategory.ThisPage;
                                break;
                        }
                        tagList.Add(url);
                    }
                    else
                    {
                        SystemTag sys = new SystemTag(tag.OuterDefineText);
                        //Util.Debug(false, res.GetType().ToString());
                        sys.SetResourceDependency(res);
                        tagList.Add(sys);
                    }
                }
                else
                {
                    tagList.Add(tag);
                }
                //Util.Debug(false, "#####\n" + tag.OuterDefineText + "\n#####");
                //TagList.Add(tag);

                idxBegin = tag.DefinedIndexEnd;
                mc = regEx.Matches(tagdef, idxBegin);
            }

            if (idxBegin < tagdef.Length)
            {
                htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin));
                tagList.Add(htmlTag);
            }
        }
Beispiel #2
0
        internal static void FilledInTagList(string tagdef, ArrayList tagList, IResourceDependency res)
        {
            int idxBegin = 0, idxEnd = 0;

            idxBegin = tagdef.IndexOf("#}");
            idxEnd   = tagdef.LastIndexOf("{#");
            tagdef   = tagdef.Substring(idxBegin + 2, idxEnd - idxBegin - 2).Trim();

            Regex regEx = new Regex(TagBase.TagDefinitionPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);

            idxBegin = idxEnd = 0;
            MatchCollection mc      = regEx.Matches(tagdef, idxBegin);
            HtmlTextTag     htmlTag = null;

            while (mc.Count > 0)
            {
                Match m = mc[0];
                idxEnd = m.Index;

                if (idxEnd > idxBegin)
                {
                    htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin, idxEnd - idxBegin));
                    tagList.Add(htmlTag);
                }

                TagBase tag = new TagBase(m.Value, m.Index, ref tagdef);
                //Util.Debug(tag.Category);
                if (tag.Category == TagCategory.AutoTag)
                {
                    AutoItem item = AutoItem.Parse(tag);
                    if (res.GetType() == typeof(PagerTag))
                    {
                        item.CallerTag = (PagerTag)res;
                    }
                    tagList.Add(item);
                }
                else if (tag.Category == TagCategory.DefineTag)
                {
                    //数据库标签定义格式为 {#%FieldName%#}
                    if (res != null)
                    {
                        htmlTag = new HtmlTextTag(res.GetDefinition(tag.OuterDefineText).ToString());
                        tagList.Add(htmlTag);
                    }
                }
                else if (tag.Category == TagCategory.CustomTag)
                {
                    #region 数据定义标签内包含数据定义标签
                    DbStoredCustomTag dbTag = DbStoredCustomTag.Parse(tag);
                    dbTag.SetResourceDependency(res);
                    if (dbTag.IsExist == true)
                    {
                        htmlTag = new HtmlTextTag(dbTag.GetTagValue().ToString());
                        tagList.Add(htmlTag);
                    }
                    #endregion
                }
                else if (tag.Category == TagCategory.SystemTag)
                {
                    string pageURLKey = ",FirstUrl,PreUrl,NextUrl,LastUrl,CurUrl,";
                    string tagName    = tag.TagName.Trim('$');
                    if (pageURLKey.IndexOf("," + tagName + ",", StringComparison.InvariantCultureIgnoreCase) != -1)
                    {
                        tagName = tagName.ToLower();
                        PageUrl url = new PageUrl(tag.OuterDefineText);
                        url.IsAutoItem = (res != null && res.GetType() == typeof(AutoItem));
                        url.SetResourceDependency(res);
                        switch (tagName)
                        {
                        case "firsturl": url.UrlCategory = PageUrlCategory.FirstPage; break;

                        case "preurl": url.UrlCategory = PageUrlCategory.PrePage; break;

                        case "nexturl": url.UrlCategory = PageUrlCategory.NextPage; break;

                        case "lasturl": url.UrlCategory = PageUrlCategory.LastPage; break;

                        case "cururl": url.UrlCategory = PageUrlCategory.ThisPage; break;

                        default:
                            url.UrlCategory = PageUrlCategory.ThisPage;
                            break;
                        }
                        tagList.Add(url);
                    }
                    else
                    {
                        SystemTag sys = new SystemTag(tag.OuterDefineText);
                        //Util.Debug(false, res.GetType().ToString());
                        sys.SetResourceDependency(res);
                        tagList.Add(sys);
                    }
                }
                else
                {
                    tagList.Add(tag);
                }
                //Util.Debug(false, "#####\n" + tag.OuterDefineText + "\n#####");
                //TagList.Add(tag);

                idxBegin = tag.DefinedIndexEnd;
                mc       = regEx.Matches(tagdef, idxBegin);
            }

            if (idxBegin < tagdef.Length)
            {
                htmlTag = new HtmlTextTag(tagdef.Substring(idxBegin));
                tagList.Add(htmlTag);
            }
        }