public ListAccessor(JArray array, IReferences refs, Func <ModelDataAccessor, T> factory) { _array = array; _refs = refs; _factory = factory; _items = array .Select(t => { var obj = refs.GetReferred((JObject)t); var accessor = new ModelDataAccessor(obj, _refs); return(factory.Invoke(accessor)); }) .ToList() ?? new List <T>(); }
private ModelDataAccessor Get(JObject parent, string name) { var property = parent.Property(name); if (property == null || property.Value is null || property.Value.Type == JTokenType.Null) { return(null); } if (!(property.Value is JObject obj)) { throw new ArgumentException($"Parameter {name} does not reference a valid reference object."); } obj = _refs.GetReferred(obj); return(new ModelDataAccessor(obj, this)); }