private ExtractionValue _extractValueRef(ExtractionValue value, string key) { if (value.Type == ValueType.Dictionary) { var dic = value.GetValue <ExtractionDic>(); if (dic.Count == 1 && dic.ContainsKey("Value") && (key == null || key == "Value")) { return(dic["Value"]); } if (key == null) { return(value); } if (!dic.ContainsKey(key)) { return(null); } return(dic[key]); } return(key == null ? value : null); }
private void _createRefDics(Node node, string sourceText, out Dictionary <string, ExtractionValue> nameDic, out Dictionary <int, ExtractionValue> numberDic ) { var rule = node.Rule; nameDic = new Dictionary <string, ExtractionValue>(); if (rule.HasStaticVars) { _setStaticVars(nameDic, rule.StaticVars); } numberDic = new Dictionary <int, ExtractionValue>(); foreach (var nodeBase in node.Children) { ExtractionValue value = _getNodeValue(nodeBase, sourceText); numberDic[nodeBase.Index] = value; if (!nodeBase.HasLocalName) { continue; } if (!nameDic.ContainsKey(nodeBase.LocalName)) { nameDic[nodeBase.LocalName] = value; } else if (nameDic[nodeBase.LocalName].Type != ValueType.List) { var listValue = new List <ExtractionValue>(); listValue.Add(nameDic[nodeBase.LocalName]); listValue.Add(value); nameDic[nodeBase.LocalName] = new ExtractionValue(listValue, ValueType.List); } else { nameDic[nodeBase.LocalName] .GetValue <List <ExtractionValue> >() .Add(value); } } }