本文整理汇总了C#中System.Script.CreateDynamicExecutionContext方法的典型用法代码示例。如果您正苦于以下问题:C# Script.CreateDynamicExecutionContext方法的具体用法?C# Script.CreateDynamicExecutionContext怎么用?C# Script.CreateDynamicExecutionContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Script
的用法示例。
在下文中一共展示了Script.CreateDynamicExecutionContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteIndexer
/// <summary>
/// Executes the specified indexer method.
/// </summary>
/// <param name="mdesc">The method descriptor</param>
/// <param name="script">The script.</param>
/// <param name="obj">The object.</param>
/// <param name="index">The indexer parameter</param>
/// <param name="value">The dynvalue to set on a setter, or null.</param>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
protected virtual DynValue ExecuteIndexer(IMemberDescriptor mdesc, Script script, object obj, DynValue index, DynValue value)
{
IList<DynValue> values;
if (index.Type == DataType.Tuple)
{
if (value == null)
{
values = index.Tuple;
}
else
{
values = new List<DynValue>(index.Tuple);
values.Add(value);
}
}
else
{
if (value == null)
{
values = new DynValue[] { index };
}
else
{
values = new DynValue[] { index, value };
}
}
CallbackArguments args = new CallbackArguments(values, false);
ScriptExecutionContext execCtx = script.CreateDynamicExecutionContext();
DynValue v = mdesc.GetValue(script, obj);
if (v.Type != DataType.ClrFunction)
throw new ScriptRuntimeException("a clr callback was expected in member {0}, while a {1} was found", mdesc.Name, v.Type);
return v.Callback.ClrCallback(execCtx, args);
}