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