public override bool TryGetMember(GetMemberBinder binder, out object result) { if (ResultDictionary.TryGetValue(binder.Name, out result) == false) { if (ResultDictionary.TryGetValue(binder.Name.ToLowerInvariant(), out result) == false) { return(false);// throw new Exception("property not found " + binder.Name); } } if (result is IDictionary <string, object> ) { result = new DynamicParser(result as IDictionary <string, object>); } else if (result is List <object> ) { List <object> list = new List <object> { }; foreach (object item in (List <object>)result) { if (item is IDictionary <string, object> ) { list.Add(new DynamicParser(item as IDictionary <string, object>)); } else { list.Add(item); } } result = list; } return(ResultDictionary.ContainsKey(binder.Name)); }
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) { object index = indexes[0]; result = index is int?ResultList[(int)index] : ResultDictionary[(string)index]; if (result is IDictionary <string, object> ) { result = new DynamicParser(result as IDictionary <string, object>); } return(true); }