public static IRuleConfig GetPageRule(Stream stream) { IRuleConfig pageRule = null; using (JsonReader jsonReader = new JsonTextReader(new StreamReader(stream))) { JObject jObject = JObject.Load(jsonReader); var jTokens = jObject["Pages"]?.AsJEnumerable(); if (jTokens != null) { var _pageRule = new RuleConfig(); foreach (var jToken in jTokens) { PageType pageType; if (!Enum.TryParse(jToken?.Value <string>("PageType"), out pageType)) { continue; } Page page = new Page(); if (Boolean.TryParse(jToken?.Value <string>("UseProxy"), out bool useProxy)) { page.UseProxy = useProxy; } var jRules = jToken["Rules"].AsJEnumerable(); foreach (var jRule in jRules) { Rule.Rule rule = new Rule.Rule() { Name = jRule?.Value <string>("Name"), XPath = jRule?.Value <string>("XPath"), Fun = (Rule.Rule.RuleFun)Enum.Parse(typeof(Rule.Rule.RuleFun), jRule?.Value <string>("Fun")), Param = jRule?.Value <string>("Param"), }; page.Add(rule); } _pageRule.AddRule(pageType, page); } pageRule = _pageRule; } } return(pageRule); }
public BCY(IRuleConfig ruleConfig) : base(ruleConfig) { //cookie = "lang_set=zh; " + // "UM_distinctid=15dde4e71e555-0d8b5ff65bd62c-791238-1fa400-15dde4e71e6904; " + // "acw_tc=AQAAAH9bHU2cSwwAh5QpeORR3Tl+HdPW; " + // "PHPSESSID=ig4cumhk9pfehocjq252mu7dv2; " + // "LOGGED_USER=Q8G5jV2ZlOcDiOYQntQTyA%3D%3D%3A2JzZVgiv4NXE5z1zq5zkJA%3D%3D; " + // "CNZZDATA1257708097=1756281233-1502672690-%7C1511333691; " + // "Hm_lvt_330d168f9714e3aa16c5661e62c00232=1511332578; " + // "Hm_lpvt_330d168f9714e3aa16c5661e62c00232=1511334642; " + // "mobile_set=no"; httpUtil.SetCookie(cookie); }
public static IApi GetApi(ApiType apiType, Stream stream) { if (apiDic is null) { IRuleConfig ruleConfig = RuleConfig.GetPageRule(stream); apiDic = new Dictionary <ApiType, IApi>(); foreach (var rule in ruleDic) { apiDic.Add(rule.Key, (IApi)Activator.CreateInstance(rule.Value, ruleConfig)); } } if (apiDic.ContainsKey(apiType)) { return(apiDic[apiType]); } return(null); }
public JDLingYu(IRuleConfig ruleConfig) { }
protected RuleEvaluationContextBase(Folder folder, MessageItem message, StoreSession session, ProxyAddress recipient, IADRecipientCache recipientCache, long mimeSize, IRuleConfig ruleConfig, Trace tracer) { if (message != null) { this.ruleHistory = message.GetRuleHistory(session); } this.message = message; this.session = session; this.cultureInfo = this.session.PreferedCulture; this.folderSet = new Dictionary <StoreId, Folder>(); this.TrackFolder(folder.Id, folder); this.folder = folder; this.recipientAddress = recipient; this.recipientCache = recipientCache; this.mimeSize = mimeSize; this.ruleConfig = ruleConfig; this.tracer = tracer; }
public BaseApi(IRuleConfig ruleConfig) { this.ruleConfig = ruleConfig; this.httpUtil = new HttpUtil(); }