本文整理汇总了C#中Castle.DynamicProxy.Generators.Emitters.ClassEmitter.CreateEvent方法的典型用法代码示例。如果您正苦于以下问题:C# ClassEmitter.CreateEvent方法的具体用法?C# ClassEmitter.CreateEvent怎么用?C# ClassEmitter.CreateEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Castle.DynamicProxy.Generators.Emitters.ClassEmitter
的用法示例。
在下文中一共展示了ClassEmitter.CreateEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollectEvents
private EventToGenerate[] CollectEvents(ArrayList methodList, Type type, bool onlyVirtuals, ClassEmitter emitter)
{
ArrayList toGenerateList = new ArrayList();
BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
EventInfo[] events = type.GetEvents(flags);
foreach(EventInfo eventInfo in events)
{
MethodInfo addMethod = eventInfo.GetAddMethod(true);
MethodInfo removeMethod = eventInfo.GetRemoveMethod(true);
bool shouldGenerate = false;
if (addMethod != null && IsAccessible(addMethod) && AcceptMethod(addMethod, onlyVirtuals))
{
shouldGenerate = true;
methodList.Add(addMethod);
}
if (removeMethod != null && IsAccessible(removeMethod) && AcceptMethod(removeMethod, onlyVirtuals))
{
shouldGenerate = true;
methodList.Add(removeMethod);
}
if (shouldGenerate == false)
continue;
EventAttributes atts = ObtainEventAttributes(eventInfo);
EventEmitter eventEmitter = emitter.CreateEvent(eventInfo.Name, atts, eventInfo.EventHandlerType);
EventToGenerate eventToGenerate = new EventToGenerate(eventEmitter, addMethod, removeMethod, atts);
toGenerateList.Add(eventToGenerate);
}
return (EventToGenerate[]) toGenerateList.ToArray(typeof(EventToGenerate));
}