private KeyValues(ParseResult result, KeyValuesFlags flags) { AssertParser(result, ".Document"); _root = new Entry(); _root.AddValue(result[0], flags); }
private KeyValues(ParseResult result, KeyValuesFlags flags) { AssertParser(result, ".Definition.List"); _root = new Entry(); _root.AddValue(result, flags); }
private bool TryGetCompatibleValue(Entry entry, Type type, ref object value) { var values = entry.Values; if (values == null) { return(false); } var dictionaryAdapter = null as IDictionaryAdapter; // Try to find in the graph a directly assignable value foreach (var item in values) { if (!item.IsInGraph) { continue; } var candidate = item.Value.Target; if (candidate == null) { continue; } if (type.IsAssignableFrom(item.Type)) { if (null != candidate) { return(Try.Success(out value, candidate)); } } if (dictionaryAdapter == null) { dictionaryAdapter = candidate as IDictionaryAdapter; } } // Fall back to coercing a DA found in the graph if (dictionaryAdapter != null) { value = dictionaryAdapter.Coerce(type); entry.AddValue(type, value, true); return(true); } return(false); }
private void AddValueCore(Entry entry, Type type, object value, bool isInGraph) { entry.AddValue(type, value, isInGraph); entriesByValue.Add(value, entry); }
private bool TryGetCompatibleValue(Entry entry, Type type, ref object value) { var values = entry.Values; if (values == null) return false; var dictionaryAdapter = null as IDictionaryAdapter; // Try to find in the graph a directly assignable value foreach (var item in values) { if (!item.IsInGraph) continue; var candidate = item.Value.Target; if (candidate == null) continue; if (type.IsAssignableFrom(item.Type)) if (null != candidate) return Try.Success(out value, candidate); if (dictionaryAdapter == null) dictionaryAdapter = candidate as IDictionaryAdapter; } // Fall back to coercing a DA found in the graph if (dictionaryAdapter != null) { value = dictionaryAdapter.Coerce(type); entry.AddValue(type, value, true); return true; } return false; }