private static async Task <object> ToSimpleObject(IBifoqlMapInternal lookup) { var values = new Dictionary <string, object>(); foreach (var pair in lookup) { var value = await pair.Value(); if (value is IBifoqlUndefined || value is IBifoqlLookupBase) { continue; } values[pair.Key] = await ToSimpleObject(value); } return(new DynamicDict(values)); }
public static Task <IBifoqlObject> Values(Location location, QueryContext context, IBifoqlMapInternal map) { var values = new List <Func <Task <IBifoqlObject> > >(); foreach (var pair in map) { values.Add(pair.Value); } return(Task.FromResult <IBifoqlObject>(new AsyncArray(values))); }
public static Task <IBifoqlObject> Unzip(Location location, QueryContext context, IBifoqlMapInternal map) { var keys = new List <Func <Task <IBifoqlObject> > >(); var values = new List <Func <Task <IBifoqlObject> > >(); foreach (var pair in map) { keys.Add(() => Task.FromResult((IBifoqlObject) new AsyncString(pair.Key))); values.Add(pair.Value); } var resultDict = new List <Func <Task <IBifoqlObject> > > { () => Task.FromResult((IBifoqlObject) new AsyncArray(keys)), () => Task.FromResult((IBifoqlObject) new AsyncArray(values)) }; return(Task.FromResult <IBifoqlObject>(new AsyncArray(resultDict))); }
public static Task <IBifoqlObject> Keys(Location location, QueryContext context, IBifoqlMapInternal map) { var keys = new List <Func <Task <IBifoqlObject> > >(); foreach (var pair in map) { keys.Add(() => Task.FromResult((IBifoqlObject) new AsyncString(pair.Key))); } return(Task.FromResult <IBifoqlObject>(new AsyncArray(keys))); }