public BETag(string s) { OK = false; if (s == null) { return; } if (s.StartsWith("{")) { BEPos bp = BETag.FormatCmd(s, '{', '}'); if (bp.Valid()) { Cmd = new Cmd(bp.String); //////////??????? s = s.Substring(bp.E + 1); } } string[] items = s.Split(new string[] { "[", "]", "-" }, StringSplitOptions.RemoveEmptyEntries); if (items.Length == 2) { Begin = items[0].Replace("@@", "-").Replace("##<", "{").Replace(">##", "}"); End = items[1].Replace("@@", "-").Replace("##<", "{").Replace(">##", "}"); } else if (items.Length == 1) { Begin = items[0].Replace("@@", "-").Replace("##<", "{").Replace(">##", "}"); End = ""; } else { return; } OK = true; }
public BETags(string Rule) { tags = new List <BETag>(); BEPos bp; if (Rule.StartsWith("{")) { bp = BETag.FormatCmd(Rule, '{', '}'); if (bp.Valid()) { string cmdstr = bp.String; ///////////////////////////////// this.Cmd = new Cmd(cmdstr); Rule = Rule.Substring(bp.E + 1); } } //Compute Rule bp = BETag.FormatCmd(Rule, '[', ']', 0); while (bp.Valid()) { BETag bt = new BETag(bp.String); if (bt.OK) { tags.Add(bt); } bp = BETag.FormatCmd(Rule, '[', ']', bp.E + 1); } //Compute Cmd }
public Cmd(string str) { string[] items = str.Split(new string[] { ";\r\n" }, StringSplitOptions.RemoveEmptyEntries); cmdkeyvalue = new Dictionary <string, string>(); foreach (string s in items) { if (s.Contains("=")) { string name = s.Substring(0, s.IndexOf('=')).Trim(); if (ValidTools.ValidName(name) && !cmdkeyvalue.ContainsKey(name)) { cmdkeyvalue[name] = s.Substring(s.IndexOf('=') + 1); } } } if (cmdkeyvalue.ContainsKey("replacetonull")) { ReplacetoNullTags = new BETags(cmdkeyvalue["replacetonull"]); } if (cmdkeyvalue.ContainsKey("addprefix")) { Prefix = cmdkeyvalue["addprefix"]; } if (cmdkeyvalue.ContainsKey("addsubfix")) { Subfix = cmdkeyvalue["addsubfix"]; } return; /////////////////////////////// if (cmdkeyvalue.ContainsKey("nexturl")) { NextUrlTags = new BETags(cmdkeyvalue["nexturl"]); } if (cmdkeyvalue.ContainsKey("nextexist")) { NextExist = cmdkeyvalue["nextexist"]; } if (cmdkeyvalue.ContainsKey("replacetemplate")) { ReplaceTemplate = cmdkeyvalue["replacetemplate"]; ReplaceTemplate = ReplaceTemplate.Replace("\\r\\n", "\r\n") .Replace("\\t", "\t"); } if (cmdkeyvalue.ContainsKey("multisubitem")) { MultiSubItemTags = new BETags(cmdkeyvalue["multisubitem"]); } if (cmdkeyvalue.ContainsKey("reversematch")) { if (cmdkeyvalue["reversematch"] == "true") { ReverseMatch = true; } } if (cmdkeyvalue.ContainsKey("txtasurl")) { if (cmdkeyvalue["txtasurl"] == "true") { TxtAsUrl = true; } } if (cmdkeyvalue.ContainsKey("dbidbeginend")) { BETags bts = new BETags(cmdkeyvalue["dbidbeginend"]); Bedbid = null; if (bts.tags.Count == 1 && ValidTools.ValidNumber(bts.tags[0].Begin) && ValidTools.ValidNumber(bts.tags[0].End)) { Bedbid = new BEId(); Bedbid.B = Convert.ToInt32(bts.tags[0].Begin); Bedbid.E = int.MaxValue; if (ValidTools.ValidNumber(bts.tags[0].End)) { Bedbid.E = Convert.ToInt32(bts.tags[0].End); } Bedbid.MoveToTop(); }//else 未设置BeDbid } if (cmdkeyvalue.ContainsKey("savepath")) { SavePath = cmdkeyvalue["savepath"]; } if (cmdkeyvalue.ContainsKey("downloadsuburl")) { string downloadsuburl = cmdkeyvalue["downloadsuburl"]; if (downloadsuburl.ToLower().Trim() == "true") { DownLoadSuburl = true; DownLoadSuburlType = "auto"; if (cmdkeyvalue.ContainsKey("downloadsuburltype")) { DownLoadSuburlType = cmdkeyvalue["downloadsuburltype"].Trim(); } } } if (cmdkeyvalue.ContainsKey("casecmd")) { BEPos bp = BETag.FormatCmd(cmdkeyvalue["casecmd"], '{', '}'); if (bp.Valid()) { string cmdstr = bp.String; caseCmd = new CaseCmd(cmdstr); } } if (cmdkeyvalue.ContainsKey("table")) { BEPos bp = BETag.FormatCmd(cmdkeyvalue["table"], '{', '}'); if (bp.Valid()) { string tablecmdstr = bp.String; tableCmd = new TableCmd(tablecmdstr); ListTable.Add(tableCmd); // 以后可以添加多个Table } } if (cmdkeyvalue.ContainsKey("tablevalue")) { BEPos bp = BETag.FormatCmd(cmdkeyvalue["tablevalue"], '{', '}'); if (bp.Valid()) { string tablecmdstr = bp.String; tablevalueCmd = new TableValueCmd(tablecmdstr); } } }