当前位置: 首页>>代码示例>>C#>>正文


C# IEventHandler.GetType方法代码示例

本文整理汇总了C#中IEventHandler.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IEventHandler.GetType方法的具体用法?C# IEventHandler.GetType怎么用?C# IEventHandler.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEventHandler的用法示例。


在下文中一共展示了IEventHandler.GetType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildHandlerInvocations

 private IEnumerable<Tuple<Type, Action<IEvent>>> BuildHandlerInvocations(IEventHandler handler)
 {
     return handler.GetType().GetInterfaces()
             .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEventHandler<>))
             .Select(i => new { HandlerInterface = i, EventType = i.GetGenericArguments()[0] })
             .Select(e => new Tuple<Type, Action<IEvent>>(e.EventType, this.BuildHandlerInvocation(handler, e.HandlerInterface, e.EventType)));
 }
开发者ID:AlexShkorParalect,项目名称:cqrs-journey-code,代码行数:7,代码来源:MessageDispatcher.cs

示例2: TryInvoke

 private static bool TryInvoke(IEventHandler eventHandler, string interfaceName, string methodName, IDictionary<string, object> arguments, out IEnumerable returnValue) {
     Type type = eventHandler.GetType();
     foreach (var interfaceType in type.GetInterfaces()) {
         if (String.Equals(interfaceType.Name, interfaceName, StringComparison.OrdinalIgnoreCase)) {
             return TryInvokeMethod(eventHandler, interfaceType, methodName, arguments, out returnValue);
         }
     }
     returnValue = null;
     return false;
 }
开发者ID:akhurst,项目名称:ricealumni,代码行数:10,代码来源:DefaultOrchardEventBus.cs

示例3: TryInvokeMethod

        private static bool TryInvokeMethod(IEventHandler eventHandler, Type interfaceType, string messageName, string interfaceName, string methodName, IDictionary<string, object> arguments, out IEnumerable returnValue) {
            var key = eventHandler.GetType().FullName + "_" + messageName + "_" + String.Join("_", arguments.Keys);
            var cachedDelegate = _delegateCache.GetOrAdd(key, k => {
                var method = GetMatchingMethod(eventHandler, interfaceType, methodName, arguments);
                return method != null
                    ? Tuple.Create(method.GetParameters(), DelegateHelper.CreateDelegate<IEventHandler>(eventHandler.GetType(), method))
                    : null;
            });

            if (cachedDelegate != null) {
                var args = cachedDelegate.Item1.Select(methodParameter => arguments[methodParameter.Name]).ToArray();
                var result = cachedDelegate.Item2(eventHandler, args);

                returnValue = result as IEnumerable;
                if (result != null && (returnValue == null || result is string))
                    returnValue = new[] { result };
                return true;
            }

            returnValue = null;
            return false;
        }
开发者ID:anycall,项目名称:Orchard,代码行数:22,代码来源:DefaultOrchardEventBus.cs

示例4: _HandleEvent

 private static void _HandleEvent(IEventHandler handler,IEvent evnt,ref Thread delThread)
 {
     delThread = Thread.CurrentThread;
     if (delThread.Name == null)
     {
         lock (_rand)
         {
             Thread.CurrentThread.Name = "EventHandlerCall{" + handler.GetType().FullName + "}[" + _rand.Next().ToString() + "]";
         }
     }
     Thread.CurrentThread.IsBackground = true;
     handler.ProcessEvent(evnt);
 }
开发者ID:marquismark,项目名称:freeswitchconfig,代码行数:13,代码来源:EventController.cs

示例5: TryInvokeMethod

        private static bool TryInvokeMethod(IEventHandler eventHandler, Type interfaceType, string methodName, IDictionary<string, object> arguments, out IEnumerable returnValue) {
            MethodInfo method = _interfaceMethodsCache.GetOrAdd(String.Concat(eventHandler.GetType().FullName + "_" + interfaceType.Name, "_", methodName, "_", String.Join("_", arguments.Keys)), GetMatchingMethod(eventHandler, interfaceType, methodName, arguments));

            if (method != null) {
                var parameters = new List<object>();
                foreach (var methodParameter in method.GetParameters()) {
                    parameters.Add(arguments[methodParameter.Name]);
                }
                var result = method.Invoke(eventHandler, parameters.ToArray());
                returnValue = result as IEnumerable;
                if (returnValue == null && result != null)
                    returnValue = new[] { result };
                return true;
            }
            returnValue = null;
            return false;
        }
开发者ID:akhurst,项目名称:ricealumni,代码行数:17,代码来源:DefaultOrchardEventBus.cs

示例6: Register

        public void Register(IEventHandler handler)
        {
            if (handler == null) throw new ArgumentNullException(nameof(handler));

            var supportedEventTypes = handler.GetType()
                .GetInterfaces()
                .Where(iface => iface.IsGenericType && iface.GetGenericTypeDefinition() == typeof(IEventHandler<>))
                .Select(iface => iface.GetGenericArguments()[0])
                .ToList();

            foreach (var eventType in supportedEventTypes)
            {
                List<IEventHandler> entry;
                if (!_handlers.TryGetValue(eventType, out entry))
                {
                    entry = new List<IEventHandler>();
                    _handlers.Add(eventType, entry);
                }

                _handlers[eventType].Add(handler);
            }
        }
开发者ID:fvilers,项目名称:Darjeel,代码行数:22,代码来源:EventHandlerRegistry.cs

示例7: TryInvoke

 private static bool TryInvoke(IEventHandler eventHandler, string messageName, string interfaceName, string methodName, IDictionary<string, object> arguments, out IEnumerable returnValue) {
     var matchingInterface = eventHandler.GetType().GetInterface(interfaceName);
     return TryInvokeMethod(eventHandler, matchingInterface, messageName, interfaceName, methodName, arguments, out returnValue);
 }
开发者ID:anycall,项目名称:Orchard,代码行数:4,代码来源:DefaultOrchardEventBus.cs

示例8: TryInvoke

 private static void TryInvoke(IEventHandler eventHandler, string interfaceName, string methodName, IDictionary<string, object> arguments)
 {
     Type type = eventHandler.GetType();
     foreach (var interfaceType in type.GetInterfaces()) {
         if (String.Equals(interfaceType.Name, interfaceName, StringComparison.OrdinalIgnoreCase)) {
             TryInvokeMethod(eventHandler, interfaceType, methodName, arguments);
             break;
         }
     }
 }
开发者ID:mofashi2011,项目名称:orchardcms,代码行数:10,代码来源:DefaultOrchardEventBus.cs


注:本文中的IEventHandler.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。