1234567891011121314151617181920212223242526 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace NTERA.Engine.Runtime
- {
- public class DynamicVariable : Variable
- {
- protected EraRuntime Runtime { get; }
- protected Func<EraRuntime, int[], Value> Predicate { get; }
- public DynamicVariable(string name, ValueType type, EraRuntime runtime, Func<EraRuntime, int[], Value> predicate) : base(name, type)
- {
- Runtime = runtime;
- Predicate = predicate;
- }
- public override Value this[params int[] index]
- {
- get => Predicate(Runtime, index);
- set => throw new EraRuntimeException("Cannot assign to a dynamic variable");
- }
- }
- }
|