本文整理汇总了C#中ICall.GetMethodInfo方法的典型用法代码示例。如果您正苦于以下问题:C# ICall.GetMethodInfo方法的具体用法?C# ICall.GetMethodInfo怎么用?C# ICall.GetMethodInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICall
的用法示例。
在下文中一共展示了ICall.GetMethodInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FormatCall
private string FormatCall(ICall call, bool isAcrossMultipleTargets, TypeInstanceNumberLookup instanceLookup)
{
var s = _callFormatter.Format(call.GetMethodInfo(), FormatArgs(call.GetArguments()));
if (!isAcrossMultipleTargets) return s;
var target = call.Target();
var methodInfo = call.GetMethodInfo();
return FormatCallForInstance(instanceLookup, target, methodInfo, s);
}
示例2: IsSatisfiedBy
public bool IsSatisfiedBy(ICall call)
{
if (_methodInfo != call.GetMethodInfo()) return false;
if (HasDifferentNumberOfArguments(call)) return false;
if (NonMatchingArguments(call).Any()) return false;
return true;
}
示例3: Handle
public RouteAction Handle(ICall call)
{
// We want the proxies to respond to the base object methods (e.g. Equals, GetHashCode)
if (call.GetMethodInfo().GetBaseDefinition().DeclaringType == typeof(object))
return RouteAction.Return(call.CallOriginalMethod());
return RouteAction.Continue();
}
示例4: CreateFrom
public ICallSpecification CreateFrom(ICall call, MatchArgs matchArgs)
{
var methodInfo = call.GetMethodInfo();
var argumentSpecs = call.GetArgumentSpecifications();
var arguments = call.GetOriginalArguments();
var parameterInfos = call.GetParameterInfos();
var argumentSpecificationsForCall = _argumentSpecificationsFactory.Create(argumentSpecs, arguments, parameterInfos, matchArgs);
return new CallSpecification(methodInfo, argumentSpecificationsForCall);
}
示例5: CreateCallToPropertyGetterFromSetterCall
public ICall CreateCallToPropertyGetterFromSetterCall(ICall callToSetter)
{
var propertyInfo = GetPropertyFromSetterCallOrNull(callToSetter);
if (!PropertySetterExistsAndHasAGetMethod(propertyInfo))
{
throw new InvalidOperationException("Could not find a GetMethod for \"" + callToSetter.GetMethodInfo() + "\"");
}
var getter = propertyInfo.GetGetMethod();
return new CallToPropertyGetter(getter, callToSetter.Target());
}
示例6: CreateCallToPropertyGetterFromSetterCall
public ICall CreateCallToPropertyGetterFromSetterCall(ICall callToSetter)
{
var propertyInfo = GetPropertyFromSetterCallOrNull(callToSetter);
if (!PropertySetterExistsAndHasAGetMethod(propertyInfo))
{
throw new InvalidOperationException("Could not find a GetMethod for \"" + callToSetter.GetMethodInfo() + "\"");
}
var setterArgs = callToSetter.GetArguments();
var getter = propertyInfo.GetGetMethod();
var getterArgs = setterArgs.Take(setterArgs.Length - 1).ToArray();
return new Call(getter, getterArgs, callToSetter.Target(), callToSetter.GetArgumentSpecifications());
}
示例7: IsSatisfiedBy
public bool IsSatisfiedBy(ICall call)
{
if (MethodInfo != call.GetMethodInfo()) return false;
var arguments = call.GetArguments();
if (arguments.Length != ArgumentSpecifications.Count) return false;
for (int i = 0; i < arguments.Length; i++)
{
var argumentMatchesSpecification = ArgumentSpecifications[i].IsSatisfiedBy(arguments[i]);
if (!argumentMatchesSpecification) return false;
}
return true;
}
示例8: Handle
public object Handle(ICall call)
{
var methodInfo = call.GetMethodInfo();
var eventInfo = methodInfo.DeclaringType.GetEvents().First(
x => (x.GetAddMethod() == methodInfo) || (x.GetRemoveMethod() == methodInfo));
var handlers = _eventHandlerRegistry.GetHandlers(eventInfo.Name);
var eventArguments = _getEventArguments(call);
foreach (Delegate handler in handlers)
{
handler.DynamicInvoke(eventArguments);
}
return null;
}
示例9: CreateFrom
public ICallSpecification CreateFrom(ICall call)
{
var result = new CallSpecification(call.GetMethodInfo());
var argumentSpecs = _context.DequeueAllArgumentSpecifications();
var arguments = call.GetArguments();
if (argumentSpecs.Count == 0)
{
AddArgumentSpecsToCallSpec(result, arguments.Select(x => (IArgumentSpecification) new ArgumentEqualsSpecification(x)));
}
else if (argumentSpecs.Count == arguments.Length)
{
AddArgumentSpecsToCallSpec(result, argumentSpecs);
}
else
{
throw new AmbiguousArgumentsException(
"Cannot determine argument specifications to use. Please use specifications for all arguments.");
}
return result;
}
示例10: Handle
public RouteAction Handle(ICall call)
{
var methodInfo = call.GetMethodInfo();
var eventInfo = methodInfo.DeclaringType.GetEvents().First(
x => (x.GetAddMethod() == methodInfo) || (x.GetRemoveMethod() == methodInfo));
var handlers = _eventHandlerRegistry.GetHandlers(eventInfo.Name);
var eventArguments = _getEventArguments(call);
foreach (Delegate handler in handlers)
{
try
{
handler.DynamicInvoke(eventArguments);
}
catch (TargetInvocationException e)
{
PreserveStackTrace(e.InnerException);
throw e.InnerException;
}
}
return RouteAction.Continue();
}
示例11: GetEvents
private IEnumerable<EventInfo> GetEvents(ICall call, Func<ICall, Predicate<EventInfo>> createPredicate)
{
var predicate = createPredicate(call);
return call.GetMethodInfo().DeclaringType.GetEvents().Where(x => predicate(x));
}
示例12: Format
public string Format(ICall call)
{
return CallFormatter.Format(call.GetMethodInfo(), FormatArguments(call.GetArguments()));
}
示例13: IsEventUnsubscription
private Predicate<EventInfo> IsEventUnsubscription(ICall call)
{
return x => call.GetMethodInfo() == x.GetRemoveMethod();
}
示例14: IsEventSubscription
private Predicate<EventInfo> IsEventSubscription(ICall call)
{
return x => call.GetMethodInfo() == x.GetAddMethod();
}
示例15: GetPropertyFromSetterCallOrNull
private PropertyInfo GetPropertyFromSetterCallOrNull(ICall call)
{
return call.GetMethodInfo().GetPropertyFromSetterCallOrNull();
}