public static TCollection GetReferences <TCollection, TChild>(this Dictionary <string, object> props, string key, LookupCache <TChild> cache) where TCollection : class, ICollection <TChild>, new() where TChild : MantisEntity, new() { TCollection result; object list; if (props.TryGetValue(key, out list)) { List <object> childProps; result = new TCollection(); childProps = (List <object>)list; for (int i = 0; i < childProps.Count; i++) { TChild item; item = cache.Get((Dictionary <string, object>)childProps[i]); result.Add(item); } } else { result = null; } return(result); }
public static T GetReference <T>(this Dictionary <string, object> props, string key, LookupCache <T> cache) where T : MantisEntity, new() { T result; object childProps; result = props.TryGetValue(key, out childProps) ? cache.Get((Dictionary <string, object>)childProps) : null; return(result); }