示例#1
0
 public override Value Process(Array.IterItem item, int length)
 {
     signal = SignalType.None;
     using (var assistant = new ParameterAssistant(parameterBlock))
     {
         var block = assistant.Block();
         assistant.ArrayParameters();
         assistant.SetParameterValues(item);
         var value = block.Evaluate();
         signal = Signal();
         return(value);
     }
 }
示例#2
0
        public override Value Fill()
        {
            using var assistant = new ParameterAssistant(Arguments);
            var   block = assistant.Block();
            Value value;

            if (block != null)
            {
                assistant.ArrayParameters();
                var index = 0;
                foreach (var key in getIndicators())
                {
                    assistant.SetParameterValues(array[key], key, index++);
                    value = block.Evaluate();
                    var signal = Signal();
                    if (signal == Breaking)
                    {
                        break;
                    }

                    switch (signal)
                    {
                    case Continuing:
                        continue;

                    case ReturningNull:
                        return(null);
                    }

                    if (value != null)
                    {
                        array[key] = value;
                    }
                }

                return(array);
            }

            value = Arguments[0];
            foreach (var key in getIndicators())
            {
                array[key] = value.Clone();
            }

            return(array);
        }
示例#3
0
        public override Value SelfMap()
        {
            using var assistant = new ParameterAssistant(Arguments);
            var block = assistant.Block();

            if (block == null)
            {
                return(this);
            }

            assistant.ArrayParameters();

            var changes = new Array();

            foreach (var key in getIndicators())
            {
                var value = array[key];
                var index = array.GetIndex(key);
                assistant.SetParameterValues(value, key, index);
                value = block.Evaluate();
                var signal = Signal();
                if (signal == Breaking)
                {
                    break;
                }

                switch (signal)
                {
                case Continuing:
                    continue;

                case ReturningNull:
                    return(null);
                }

                if (value.Type == ValueType.Nil)
                {
                    continue;
                }

                if (value is KeyedValue keyedValue)
                {
                    changes[keyedValue.Key] = keyedValue.Value;
                }
                else
                {
                    changes[key] = value;
                }
            }

            if (changes.Length == 0)
            {
                return(this);
            }

            foreach (var item in changes)
            {
                array[item.Key] = item.Value;
            }

            return(this);
        }