protected bool arrayContains(StoryVar arr, StoryVar value, int position = 0) { if (position > 0) { return(arr.ConvertValueTo <List <StoryVar> >().Skip(position).Contains(value)); } else { return(arr.ConvertValueTo <List <StoryVar> >().Contains(value)); } }
public StoryVar datanames(StoryVar datamap) { return(new HarloweArray(datamap.ConvertValueTo <HarloweDatamap>().Dictionary.Keys .OrderBy(key => key, StringComparer.InvariantCulture) .Select(key => new StoryVar(key)) )); }
protected StoryVar objGet(StoryVar obj, string key) { StoryVar output = default(StoryVar); obj.ConvertValueTo <Dictionary <string, StoryVar> >().TryGetValue(key, out output); return(output); }
public StoryVar datavalues(StoryVar datamap) { return(new HarloweArray(datamap.ConvertValueTo <HarloweDatamap>().Dictionary .OrderBy(pair => pair.Key, StringComparer.InvariantCulture) .Select(pair => pair.Value) )); }
protected StoryVar arrayDeleteAt(StoryVar arr, params int[] indices) { var curArr = arr.ConvertValueTo <List <StoryVar> >(); var newArr = new List <StoryVar>(); foreach (int index in indices.OrderByDescending(i => i)) { newArr.Add(curArr[index]); curArr.RemoveAt(index); } return(new StoryVar(newArr)); }
protected StoryVar arrayDelete(StoryVar arr, params StoryVar[] values) { var newArr = new List <StoryVar>(); arr.ConvertValueTo <List <StoryVar> >().RemoveAll(v => { bool remove = values.Contains(v); if (remove) { newArr.Add(v); } return(remove); }); return(new StoryVar(newArr)); }
protected bool arrayContainsAny(StoryVar arr, params StoryVar[] values) { var curArr = arr.ConvertValueTo <List <StoryVar> >(); return(values.Any(val => curArr.Contains(val))); }
protected bool objContains(StoryVar obj, string key) { return(obj.ConvertValueTo <Dictionary <string, StoryVar> >().ContainsKey(key)); }
protected int objLength(StoryVar obj) { return(obj.ConvertValueTo <Dictionary <string, StoryVar> >().Count); }
protected void objDelete(StoryVar obj, string key) { obj.ConvertValueTo <Dictionary <string, StoryVar> >().Remove(key); }
protected void objSet(StoryVar obj, string key, StoryVar value) { obj.ConvertValueTo <Dictionary <string, StoryVar> >()[key] = value; }
protected int arrayCount(StoryVar arr, StoryVar value, int position = 0) { return(arr.ConvertValueTo <List <StoryVar> >().Skip(position).Count(v => v == value)); }
protected StoryVar arraySet(StoryVar arr, int index, StoryVar value) { return(arr.ConvertValueTo <List <StoryVar> >()[index] = value); }
protected void arrayInsert(StoryVar arr, int index, StoryVar value) { arr.ConvertValueTo <List <StoryVar> >().Insert(index, value); }
protected void arrayAdd(StoryVar arr, StoryVar value) { arr.ConvertValueTo <List <StoryVar> >().Add(value); }
protected int arrayIndexOf(StoryVar arr, StoryVar value) { return(arr.ConvertValueTo <List <StoryVar> >().IndexOf(value)); }
protected int arrayLength(StoryVar arr) { return(arr.ConvertValueTo <List <StoryVar> >().Count); }
public StoryVar count(StoryVar array, StoryVar item) { return(array.ConvertValueTo <HarloweArray>().Values.Where(elem => elem == item).Count()); }
protected StoryVar arrayGet(StoryVar arr, int index) { return(arr.ConvertValueTo <List <StoryVar> >()[index]); }