示例#1
0
 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));
     }
 }
示例#2
0
 public StoryVar datanames(StoryVar datamap)
 {
     return(new HarloweArray(datamap.ConvertValueTo <HarloweDatamap>().Dictionary.Keys
                             .OrderBy(key => key, StringComparer.InvariantCulture)
                             .Select(key => new StoryVar(key))
                             ));
 }
示例#3
0
        protected StoryVar objGet(StoryVar obj, string key)
        {
            StoryVar output = default(StoryVar);

            obj.ConvertValueTo <Dictionary <string, StoryVar> >().TryGetValue(key, out output);
            return(output);
        }
示例#4
0
 public StoryVar datavalues(StoryVar datamap)
 {
     return(new HarloweArray(datamap.ConvertValueTo <HarloweDatamap>().Dictionary
                             .OrderBy(pair => pair.Key, StringComparer.InvariantCulture)
                             .Select(pair => pair.Value)
                             ));
 }
示例#5
0
        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));
        }
示例#6
0
        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));
        }
示例#7
0
        protected bool arrayContainsAny(StoryVar arr, params StoryVar[] values)
        {
            var curArr = arr.ConvertValueTo <List <StoryVar> >();

            return(values.Any(val => curArr.Contains(val)));
        }
示例#8
0
 protected bool objContains(StoryVar obj, string key)
 {
     return(obj.ConvertValueTo <Dictionary <string, StoryVar> >().ContainsKey(key));
 }
示例#9
0
 protected int objLength(StoryVar obj)
 {
     return(obj.ConvertValueTo <Dictionary <string, StoryVar> >().Count);
 }
示例#10
0
 protected void objDelete(StoryVar obj, string key)
 {
     obj.ConvertValueTo <Dictionary <string, StoryVar> >().Remove(key);
 }
示例#11
0
 protected void objSet(StoryVar obj, string key, StoryVar value)
 {
     obj.ConvertValueTo <Dictionary <string, StoryVar> >()[key] = value;
 }
示例#12
0
 protected int arrayCount(StoryVar arr, StoryVar value, int position = 0)
 {
     return(arr.ConvertValueTo <List <StoryVar> >().Skip(position).Count(v => v == value));
 }
示例#13
0
 protected StoryVar arraySet(StoryVar arr, int index, StoryVar value)
 {
     return(arr.ConvertValueTo <List <StoryVar> >()[index] = value);
 }
示例#14
0
 protected void arrayInsert(StoryVar arr, int index, StoryVar value)
 {
     arr.ConvertValueTo <List <StoryVar> >().Insert(index, value);
 }
示例#15
0
 protected void arrayAdd(StoryVar arr, StoryVar value)
 {
     arr.ConvertValueTo <List <StoryVar> >().Add(value);
 }
示例#16
0
 protected int arrayIndexOf(StoryVar arr, StoryVar value)
 {
     return(arr.ConvertValueTo <List <StoryVar> >().IndexOf(value));
 }
示例#17
0
 protected int arrayLength(StoryVar arr)
 {
     return(arr.ConvertValueTo <List <StoryVar> >().Count);
 }
示例#18
0
 public StoryVar count(StoryVar array, StoryVar item)
 {
     return(array.ConvertValueTo <HarloweArray>().Values.Where(elem => elem == item).Count());
 }
示例#19
0
 protected StoryVar arrayGet(StoryVar arr, int index)
 {
     return(arr.ConvertValueTo <List <StoryVar> >()[index]);
 }