/// <summary> /// 指定したキーで上流のKeyValueStoreから値を取得する。 /// </summary> /// <param name="rawler"></param> /// <param name="key"></param> /// <returns></returns> public static string GetValueByKey(RawlerBase rawler, string key) { KeyValueStore[] r = null; if (ancestorKeyValueStoreDic.ContainsKey(rawler)) { ancestorKeyValueStoreDic[rawler].TryGetTarget(out r); } if (r == null) { r = rawler.GetAncestorRawler().OfType <KeyValueStore>().ToArray(); if (ancestorKeyValueStoreDic.ContainsKey(rawler)) { ancestorKeyValueStoreDic[rawler].SetTarget(r); } else { ancestorKeyValueStoreDic.Add(rawler, new WeakReference <KeyValueStore[]>(r)); } } string val = null; foreach (var item in r) { if (item.dic.ContainsKey(key)) { val = item.dic[key]; break; } } if (val == null) { ReportManage.ErrReport(rawler, "key:" + key + "が見つかりません"); } return(val); }
private static string GetTopComment(RawlerBase sender) { if (visbleTopObjectComment) { return(sender.GetAncestorRawler().Last().Comment + ":"); } else { return(string.Empty); } }