本文整理汇总了C#中System.Reflection.EventInfo.GetInvokeMethod方法的典型用法代码示例。如果您正苦于以下问题:C# EventInfo.GetInvokeMethod方法的具体用法?C# EventInfo.GetInvokeMethod怎么用?C# EventInfo.GetInvokeMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.EventInfo
的用法示例。
在下文中一共展示了EventInfo.GetInvokeMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateEventAspect
public static void ValidateEventAspect(IAspect aspect, EventInfo @event)
{
var comparedTypes = Type.EmptyTypes;
var invokeMethod = @event.GetInvokeMethod();
var methodIsFunction = invokeMethod.IsFunction();
var methodParameters = invokeMethod.GetParameters();
var overridenMethods = aspect.AspectType
.GetOverridenMethods()
.ToArray(overridenMethod => {
return overridenMethod.Name.Equals("OnAddHandler") ||
overridenMethod.Name.Equals("OnInvokeHandler") ||
overridenMethod.Name.Equals("OnRemoveHandler");
});
if (!typeof(IEventInterceptionAspect).IsAssignableFrom(aspect.AspectType)) {
var argumentException = new ArgumentException(Resources.EventInterceptionAspectAttributeErrorInitialization, "aspectType");
throw new AspectAnnotationException(argumentException);
}
if (overridenMethods.Length == 0) {
throw new AdviceNotFoundException(aspect.GetType());
}
overridenMethods.ForEach(overridenMethod => {
Type argumentsType = null;
var eventName = @event.Name;
Type[] genericArguments = null;
var aspectParameters = overridenMethod.GetParameters();
var aspectMethodIsFunction = overridenMethod.IsFunction();
if (aspectParameters.Length != 1 || aspectMethodIsFunction) {
throw new AspectTypeMismatchException(Resources.AspectEventParametersMismatach.Fmt(eventName));
}
argumentsType = aspectParameters[0].ParameterType;
genericArguments = argumentsType.GetGenericArguments();
if (methodIsFunction) {
var argumentsLength = 0;
Type aspectReturnType = null;
if (typeof(IEventActionInterceptionArgs).IsAssignableFrom(argumentsType)) {
throw new AspectAnnotationException(Resources.EventActionInterceptionAspcetMismatch);
}
if (genericArguments.Length == 0) {
throw new AspectTypeMismatchException(Resources.AspectReturnTypeMismatch.Fmt(eventName));
}
argumentsLength = genericArguments.Length - 1;
aspectReturnType = genericArguments[argumentsLength];
if (genericArguments.Length > 1) {
comparedTypes = genericArguments.Take(argumentsLength)
.ToArray();
}
if (!ValidateTypesAreEqual(invokeMethod.ReturnType, aspectReturnType)) {
throw new AspectTypeMismatchException(Resources.AspectReturnTypeMismatch.Fmt(eventName));
}
}
else {
comparedTypes = genericArguments;
if (typeof(IEventFunctionInterceptionArgs).IsAssignableFrom(argumentsType)) {
throw new AspectAnnotationException(Resources.EventActionInterceptionAspcetMismatch);
}
}
if (!ValidateParameters(methodParameters, comparedTypes)) {
throw new AspectTypeMismatchException(Resources.AspectEventParametersMismatach.Fmt(eventName));
}
});
}
示例2: BindingRaiseEventAspectDecoratorWeaver
internal BindingRaiseEventAspectDecoratorWeaver(EventInfo @event, IAspectWeavingSettings aspectWeavingSettings)
: base(@event.GetInvokeMethod(), aspectWeavingSettings.WeavingSettings)
{
[email protected] = @event;
}
示例3: CompositeRaiseEventMap
public CompositeRaiseEventMap(Type contractType, Type implementationType, EventInfo contractEvent, EventInfo implementationEvent, IAspectDefinitionCollection aspectDefinitions)
: base(contractType, implementationType, contractEvent, implementationEvent, aspectDefinitions)
{
FragmentMethod = contractEvent.GetInvokeMethod();
}