Exemplo n.º 1
0
        /// <summary>
        /// 以CustomEditorButtonInfo数组
        /// </summary>
        /// <returns></returns>
        public static CustomEditorButtonInfo[] GetCustomEditButtonListWithInfo()
        {
            IDataReader iDataReader = DatabaseProvider.GetInstance().GetCustomEditButtonList();
            List<CustomEditorButtonInfo> buttonList = new List<CustomEditorButtonInfo>();
            while (iDataReader.Read())
            {
                CustomEditorButtonInfo buttonInfo = new CustomEditorButtonInfo();
                buttonInfo.Id = TypeConverter.ObjectToInt(iDataReader["id"]);
                buttonInfo.Tag = iDataReader["Tag"].ToString();
                buttonInfo.Icon = iDataReader["Icon"].ToString();
                buttonInfo.Available = TypeConverter.ObjectToInt(iDataReader["Available"]);
                buttonInfo.Example = iDataReader["Example"].ToString();
                buttonInfo.Explanation = iDataReader["Explanation"].ToString();
                buttonInfo.Params = TypeConverter.ObjectToInt(iDataReader["Params"]);
                buttonInfo.Nest = TypeConverter.ObjectToInt(iDataReader["Nest"]);
                buttonInfo.Paramsdefvalue = iDataReader["Paramsdefvalue"].ToString();
                buttonInfo.Paramsdescript = iDataReader["Paramsdescript"].ToString();
                buttonInfo.Replacement = iDataReader["Replacement"].ToString();
                buttonList.Add(buttonInfo);
            }
            iDataReader.Close();

            return buttonList.ToArray();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 转换自定义标签
        /// </summary>
        /// <param name="sDetail">帖子内容</param>
        /// <param name="__customeditorbuttoninfo">自定义标签数组</param>
        /// <returns>帖子内容</returns>
        private static string ReplaceCustomTag(string sDetail, CustomEditorButtonInfo[] customeditorbuttoninfo)
        {
            if (customeditorbuttoninfo == null)
                return sDetail;

            string replacement = "";
            int b_params = 0;
            string tempReplacement;

            Match m;

            for (int i = 0; i < Editors.regexCustomTag.Length; i++)
            {
                replacement = customeditorbuttoninfo[i].Replacement;
                b_params = customeditorbuttoninfo[i].Params;

                for (int k = 0; k < customeditorbuttoninfo[i].Nest; k++)
                {
                    for (m = Editors.regexCustomTag[i].Match(sDetail); m.Success; m = m.NextMatch())
                    {
                        tempReplacement = replacement.Replace(@"{1}", m.Groups[m.Groups.Count - 1].ToString());
                        if (b_params > 1)
                        {
                            for (int j = 2; j <= b_params; j++)
                            {
                                if (m.Groups.Count > j)
                                    tempReplacement = tempReplacement.Replace("{" + j + "}", m.Groups[j].ToString());
                            }
                        }
                        sDetail = sDetail.Replace(m.Groups[0].ToString(), tempReplacement);
                        sDetail = sDetail.Replace("{RANDOM}", Guid.NewGuid().ToString());
                    }
                }
            }
            return sDetail;
        }