本文整理汇总了C#中ScriptContext.DeclareFunction方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptContext.DeclareFunction方法的具体用法?C# ScriptContext.DeclareFunction怎么用?C# ScriptContext.DeclareFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptContext
的用法示例。
在下文中一共展示了ScriptContext.DeclareFunction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Declare
/// <summary>
/// Declares types unconditionally declared in this module on the given <see cref="ScriptContext"/>.
/// Although, we can emit the Declare helper, it is not necessary as we can do it here for types
/// and functions. Only constants, which cannot be evaluated at compile time (they are dependent
/// on other eval-time evaluated constants are emitted (TODO).
/// </summary>
public void Declare(ScriptContext/*!*/ context)
{
if (bakedTypes != null)
{
foreach (KeyValuePair<string, PhpTypeDesc> entry in bakedTypes)
{
//// checks for conflict on AC:
//if (module.Assembly.ApplicationContext.Types.ContainsKey(entry.Key))
// PhpException.Throw(PhpError.Error, CoreResources.GetString("type_redeclared", entry.Key));
// checks for conflict on SC:
if (entry.Value.IsGeneric)
context.DeclareGenericType(entry.Value, entry.Key);
else
context.DeclareType(entry.Value, entry.Key);
// moved to TypesProvider.FindAndProvideType
//
//// When class is compiled in runtime, autoload is invoked on base class (if isn't already declared).
//// We have to call autoload on the base class also in transient assembly
//if (entry.Value.Base is PhpTypeDesc)
//{
// var baseDesc = context.ResolveType(entry.Value.Base.MakeSimpleName(), null, caller, null, ResolveTypeFlags.UseAutoload);
// // if (baseDesc != entry.Value.Base) we have to invalidate the cache
//}
}
}
if (bakedFunctions != null)
{
foreach (KeyValuePair<string, PhpRoutineDesc> entry in bakedFunctions)
{
//// checks for conflict on AC:
//if (module.Assembly.ApplicationContext.Functions.ContainsKey(entry.Key))
// PhpException.Throw(PhpError.Error, CoreResources.GetString("type_redeclared", entry.Value));
// checks for conflict on SC:
context.DeclareFunction(new PhpRoutineDesc(entry.Value.MemberAttributes, entry.Value.ArglessStub, false), entry.Key);
}
}
if (bakedConstants != null)
{
foreach (var entry in this.bakedConstants)
{
// checks for conflict on SC:
//if (constant.HasValue)
context.DeclareConstant(entry.Key, entry.Value.LiteralValue);
}
}
}