// Trips($filter=contains(Name, {f5eac763-e025-4cf8-aa1d-9bb3a2986515}) $select=Id,Name $orderby=Id desc $expand=Hotels),Contacts($filter=Name eq {670bc07f-6b33-47fb-be01-63834e25ff21}) protected ExpandNode[] Compose(string value, XElement parentSchema, string parentPath) { List <ExpandNode> expands = new List <ExpandNode>(); string val = value; // Dictionary <string, string> placeholders = new Dictionary <string, string>(); val = Regex.Replace(val, ParenthesesPairPattern, new MatchEvaluator(m => { string guid = GetGuid(); placeholders.Add(guid, m.Value); return(guid); })); // string[] expandStrings = val.Split(','); for (int i = 0; i < expandStrings.Length; i++) { string expandString = expandStrings[i].Trim(); expandString = DecodeString(expandString, placeholders); string property = GetProperty(expandString, out string select, out string filter, out string orderby, out string expand); XElement[] propertyPath = Schema.GenerateExpandPropertyPath(parentSchema, property); ExpandProperty oProperty = ExpandProperty.Create(property, propertyPath, parentSchema, Schema); string path = parentPath + "/" + property; ExpandNode oExpand = ExpandNode.Create(oProperty, select, filter, orderby, Schema, Parameters); oExpand.Path = path; expands.Add(oExpand); // if (!string.IsNullOrWhiteSpace(expand)) { oExpand.Children = Compose(expand, propertyPath[propertyPath.Length - 1], path); } } return(expands.ToArray()); }
protected ExpandNode Compose(Expand expand, XElement parentSchema, string parentPath) { string property = expand.Property; XElement[] propertyPath = Schema.GenerateExpandPropertyPath(parentSchema, property); ExpandProperty oProperty = ExpandProperty.Create(property, propertyPath, parentSchema, Schema); string path = parentPath + "/" + property; ExpandNode oExpand = ExpandNode.Create(oProperty, expand.Select, expand.Filter, expand.Orderby, Schema, Parameters); oExpand.Path = path; oExpand.Children = new ExpandNode[expand.Children.Length]; for (int i = 0; i < expand.Children.Length; i++) { oExpand.Children[i] = Compose(expand.Children[i], propertyPath[propertyPath.Length - 1], path); } return(oExpand); }