/// <summary> /// Gets the item specified of the mapped type /// </summary> /// <param name="ID">ID of the item</param> /// <param name="Mappings">Mappings</param> /// <param name="EmbeddedProperties">Properties to embed</param> /// <returns>The item specified</returns> public Dynamo Any(string ID, MappingHolder Mappings, params string[] EmbeddedProperties) { if (string.IsNullOrEmpty(ID)) { throw new ArgumentNullException(nameof(ID)); } ClassType Object = AnyFunc(ID); if (!CanGetFunc(Object)) { return(null); } var TempItem = new Dynamo(Object); Dynamo ReturnValue = TempItem.SubSet(Properties.Where(x => x is IReference || x is IID) .Select(x => x.Name) .ToArray()); string AbsoluteUri = HttpContext.Current != null?HttpContext.Current.Request.Url.AbsoluteUri.Left(HttpContext.Current.Request.Url.AbsoluteUri.IndexOf('?')) : ""; if (!AbsoluteUri.EndsWith("/", StringComparison.Ordinal)) { AbsoluteUri += "/"; } foreach (IAPIProperty Property in Properties.Where(x => x is IMap)) { ReturnValue[Property.Name] = EmbeddedProperties.Contains(Property.Name) ? (object)Property.GetValue(Mappings, TempItem) : (object)(AbsoluteUri + Property.Name); } return(ReturnValue); }
/// <summary> /// Gets all items of the mapped type /// </summary> /// <param name="EmbeddedProperties">Properties to embed</param> /// <param name="Mappings">Mappings</param> /// <returns>All items of the mapped type</returns> public IEnumerable <Dynamo> All(MappingHolder Mappings, params string[] EmbeddedProperties) { IEnumerable <ClassType> Objects = AllFunc(); if (Objects == null) { Objects = new List <ClassType>(); } var ReturnValue = new List <Dynamo>(); foreach (ClassType Object in Objects) { if (CanGetFunc(Object)) { var TempItem = new Dynamo(Object); Dynamo ReturnItem = TempItem.SubSet(Properties.Where(x => x is IReference || x is IID) .Select(x => x.Name) .ToArray()); string AbsoluteUri = HttpContext.Current != null?HttpContext.Current.Request.Url.AbsoluteUri.Left(HttpContext.Current.Request.Url.AbsoluteUri.IndexOf('?')) : ""; AbsoluteUri = AbsoluteUri.Check(""); if (!AbsoluteUri.EndsWith("/", StringComparison.Ordinal)) { AbsoluteUri += "/"; } AbsoluteUri += Properties.FirstOrDefault(x => x is IID).GetValue(Mappings, Object).ToString() + "/"; foreach (IAPIProperty Property in Properties.Where(x => x is IMap)) { ReturnItem[Property.Name] = EmbeddedProperties.Contains(Property.Name) ? (object)Property.GetValue(Mappings, TempItem) : (object)(AbsoluteUri + Property.Name); } ReturnValue.Add(ReturnItem); } } return(ReturnValue); }