51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Upsilon.Evaluator;
|
|
|
|
namespace Upsilon.BaseTypes.ScriptTable
|
|
{
|
|
public class NumeratedScriptTable : ScriptTable, IEnumerable<ScriptType>
|
|
{
|
|
public NumeratedScriptTable(EvaluationScope scope) : base(scope)
|
|
{
|
|
}
|
|
|
|
public override IEnumerator<ScriptType> GetScriptEnumerator()
|
|
{
|
|
foreach (var variable in EvaluationScope.Variables)
|
|
{
|
|
yield return variable.Key.ToScriptType();
|
|
}
|
|
}
|
|
|
|
public override bool Contains(ScriptType obj)
|
|
{
|
|
return EvaluationScope.Variables.Values.Contains(obj);
|
|
}
|
|
|
|
|
|
public override System.Type GetCSharpType()
|
|
{
|
|
return typeof(IEnumerable<object>);
|
|
}
|
|
|
|
public override object ToCSharpObject()
|
|
{
|
|
return EvaluationScope.Variables.Select(x => x.Value.ToCSharpObject()).ToArray();
|
|
}
|
|
|
|
public IEnumerator<ScriptType> GetEnumerator()
|
|
{
|
|
foreach (var variable in EvaluationScope.Variables)
|
|
{
|
|
yield return variable.Value;
|
|
}
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return GetEnumerator();
|
|
}
|
|
}
|
|
} |