本文整理汇总了C#中Pchp.Core.Context.GetDeclaredType方法的典型用法代码示例。如果您正苦于以下问题:C# Context.GetDeclaredType方法的具体用法?C# Context.GetDeclaredType怎么用?C# Context.GetDeclaredType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pchp.Core.Context
的用法示例。
在下文中一共展示了Context.GetDeclaredType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: interface_exists
/// <summary>
/// Tests whether a given interface is defined.
/// </summary>
/// <param name="ctx">Current runtime context.</param>
/// <param name="ifaceName">The name of the interface.</param>
/// <param name="autoload">Whether to attempt to call <c>__autoload</c>.</param>
/// <returns><B>true</B> if the interface given by <paramref name="ifaceName"/> has been defined,
/// <B>false</B> otherwise.</returns>
public static bool interface_exists(Context ctx, string ifaceName, bool autoload = true)
{
var info = ctx.GetDeclaredType(ifaceName);
if (info == null && autoload)
{
throw new NotImplementedException("autoload");
}
//
return info != null && info.Type.GetTypeInfo().IsInterface;
}
示例2: class_exists
/// <summary>
/// Tests whether a given class is defined.
/// </summary>
/// <param name="ctx">Current runtime context.</param>
/// <param name="className">The name of the class.</param>
/// <param name="autoload">Whether to attempt to call <c>__autoload</c>.</param>
/// <returns><B>true</B> if the class given by <paramref name="className"/> has been defined,
/// <B>false</B> otherwise.</returns>
public static bool class_exists(Context ctx, string className, bool autoload = true)
{
var info = ctx.GetDeclaredType(className);
if (info == null && autoload)
{
throw new NotImplementedException("autoload");
}
//
return info != null;
}
示例3: BindCore
protected override PhpCallable BindCore(Context ctx)
{
PhpTypeInfo tinfo;
if (_item1.IsObject)
{
tinfo = _item1.Object.GetType().GetPhpTypeInfo();
}
else
{
tinfo = ctx.GetDeclaredType(_item1.ToString(ctx));
}
var method = _item2.ToString(ctx);
for (; tinfo != null; tinfo = tinfo.BaseType)
{
var routine = (PhpMethodInfo)tinfo.DeclaredMethods[method];
if (routine != null)
{
return routine.PhpInvokable.Bind(_item1.IsObject ? _item1.Object : null);
}
}
return null;
}