本文整理汇总了C#中DTypeDesc.GetMethod方法的典型用法代码示例。如果您正苦于以下问题:C# DTypeDesc.GetMethod方法的具体用法?C# DTypeDesc.GetMethod怎么用?C# DTypeDesc.GetMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DTypeDesc
的用法示例。
在下文中一共展示了DTypeDesc.GetMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStaticMethodDesc
/// <summary>
/// Attemps to find a method desc according to a given class name and method name. Used when
/// a non-virtual dispatch is about to be performed and when a <c>array(class, method)</c>
/// callback is being bound.
/// </summary>
/// <param name="requestedType">The type whose method should be returned.</param>
/// <param name="methodName">The method name.</param>
/// <param name="self">Current <c>$this</c>. Will be set to an instance, on which the resulting
/// CLR method should be invoked (<B>null</B> if the CLR method is static).</param>
/// <param name="caller"><see cref="Type"/> of the object that request the lookup.</param>
/// <param name="context">Current <see cref="ScriptContext"/>.</param>
/// <param name="quiet">If <B>true</B>, no exceptions will be thrown if an error occurs.</param>
/// <param name="removeFrame">If <B>true</B>, <see cref="PhpStack.RemoveFrame"/> will be called
/// before throwing an exception.</param>
/// <param name="isCallerMethod">Will be set to true, if required method was not found but __callStatic was.</param>
/// <returns>The <see cref="DRoutineDesc"/> or <B>null</B> on error.</returns>
internal static DRoutineDesc GetStaticMethodDesc(DTypeDesc requestedType, string methodName, ref DObject self,
DTypeDesc caller, ScriptContext context, bool quiet, bool removeFrame, out bool isCallerMethod)
{
Debug.Assert(requestedType != null);
isCallerMethod = false;
DRoutineDesc method;
GetMemberResult result = requestedType.GetMethod(new Name(methodName), caller, out method);
if (result == GetMemberResult.NotFound)
{
// if not found, perform __callStatic or __call 'magic' method lookup
Name callMethod = (self != null && requestedType.IsAssignableFrom(self.TypeDesc)) ?
Name.SpecialMethodNames.Call : Name.SpecialMethodNames.CallStatic;
if ((result = requestedType.GetMethod(callMethod, caller, out method)) != GetMemberResult.NotFound)
{
isCallerMethod = true;
}
else
{
// there is no such method in the class
if (removeFrame) context.Stack.RemoveFrame();
if (!quiet) PhpException.UndefinedMethodCalled(requestedType.MakeFullName(), methodName);
return null;
}
}
if (result == GetMemberResult.BadVisibility)
{
if (removeFrame) context.Stack.RemoveFrame();
if (!quiet)
{
PhpException.MethodNotAccessible(
method.DeclaringType.MakeFullName(),
method.MakeFullName(),
(caller == null ? String.Empty : caller.MakeFullName()),
method.IsProtected);
}
return null;
}
// check whether the method is abstract
if (method.IsAbstract)
{
if (removeFrame) context.Stack.RemoveFrame();
if (!quiet) PhpException.AbstractMethodCalled(method.DeclaringType.MakeFullName(), method.MakeFullName());
return null;
}
if (method.IsStatic)
{
self = null;
}
else
{
// check whether self is of acceptable type
if (self != null && !method.DeclaringType.RealType.IsInstanceOfType(self.RealObject)) self = null;
/*
// PHP allows for static invocations of instance method
if (self == null &&
(requestedType.IsAbstract || !(requestedType is PhpTypeDesc)) &&
(method.DeclaringType.IsAbstract || !(method.DeclaringType is PhpTypeDesc)))
{
// calling instance methods declared in abstract classes statically through abstract classes
// is unsupported - passing null as 'this' to such instance method could result in
// NullReferenceException even if the method does not touch $this
if (removeFrame) context.Stack.RemoveFrame();
if (!quiet)
{
PhpException.Throw(PhpError.Error, CoreResources.GetString("nonstatic_method_called_statically",
method.DeclaringType.MakeFullName(), method.MakeFullName()));
}
return null;
}
if (self == null)
{
if (!quiet && !context.Config.Variables.ZendEngineV1Compatible)
//.........这里部分代码省略.........
示例2: GetNonConflictingMethodName
/// <summary>
/// Creates a name based on <paramref name="str"/> that does not clash with any methods in the given type desc.
/// </summary>
internal static string/*!*/ GetNonConflictingMethodName(DTypeDesc/*!*/ typeDesc, string/*!*/ str, out bool changed)
{
Name name = new Name(str);
changed = false;
while (typeDesc.GetMethod(name) != null)
{
name = new Name(name.Value + "_");
changed = true;
}
return name.Value;
}