本文整理匯總了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);
}