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


C# Event.GetType方法代码示例

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


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

示例1: GetHeader

 /// <summary>
 /// Returns an header from an InfoEvent.
 /// </summary>
 /// <param name="Event"></param>
 /// <returns></returns>
 public static short GetHeader(Event Event)
 {
     using (DictionaryAdapter<string, short> DA = new DictionaryAdapter<string, short>(InfoEvents))
     {
         return DA.TryPopValue(Event.GetType().Name);
     }
 }
开发者ID:habb0,项目名称:PiciEmulator,代码行数:12,代码来源:StaticClientMessageHandler.cs

示例2: UniqueEvent

 protected UniqueEvent(Guid identity, Event @event, DateTime raisedTimestamp)
 {
     Identity = identity;
     UntypedEvent = @event;
     RaisedTimestamp = raisedTimestamp;
     EventType = @event.GetType();
     ConsumptionRecords = new List<ConsumptionRecord>();
 }
开发者ID:AndyHitchman,项目名称:Honeycomb,代码行数:8,代码来源:UniqueEvent.cs

示例3: add

 public void add(Event e)
 {
     if (!HiddenAccessN.isCriticalEvent(e))
     {
         HiddenAccessN.setEventPriority(e, getEventPriority(e.GetType().Name));
     }
     HiddenAccessN.setEventTime(e, getTime());
     addImpl(e);
 }
开发者ID:jccjames422,项目名称:SRE-RoboCode,代码行数:9,代码来源:EventManager.cs

示例4: Publish

        /// <summary>
        /// Publishes event to multiple or none subscribers (handlers).
        /// </summary>
        /// <param name="event">Event to publish.</param>
        public void Publish(Event @event)
        {
            var type = typeof(IEventHandler<>).MakeGenericType(@event.GetType());
            foreach (var handler in resolver.ResolveMultiple(type))
            {
                var instance = handler;
                var method = instance.GetType().GetMethod(
                                "Handle", new[] { @event.GetType() });

                if (method == null)
                {
                    throw new ApplicationException(
                        "IEventHandler doesn't contain Handle method. Make sure it was not renamed.");
                }

                method.Invoke(instance, new object[] { @event });
            }
        }
开发者ID:titarenko,项目名称:Cqrsnes,代码行数:22,代码来源:SimpleBus.cs

示例5: Add

 /// <summary>
 /// Adds an event to the event queue.
 /// </summary>
 /// <param name="evnt">is the event to add to the event queue.</param>
 public void Add(Event evnt)
 {
     if (!HiddenAccessN.IsCriticalEvent(evnt))
     {
         int priority = GetEventPriority(evnt.GetType().Name);
         HiddenAccessN.SetEventPriority(evnt, priority);
     }
     AddImpl(evnt);
 }
开发者ID:Chainie,项目名称:robocode,代码行数:13,代码来源:EventManager.cs

示例6: ApplyChange

        private void ApplyChange(Event @event, bool isNew)
        {
            dynamic d = this;

            d.Handle(Converter.ChangeTo(@event, @event.GetType()));
            if (isNew)
            {
                _changes.Add(@event);
            }
        }      
开发者ID:andyhoyle,项目名称:Crucial.Framework,代码行数:10,代码来源:AggregateRoot.cs

示例7: BroadcastEvent

        public void BroadcastEvent(Event eventToBroadcast)
        {
            List<EventListenerContainer> eventListeners = eventListenerContainerMap[eventToBroadcast.GetType()];

            if (eventListeners != null)
            {
                foreach (EventListenerContainer eventListener in eventListeners)
                {
                    eventListener.EventListenerMethod.Invoke(eventListener.Instance, new object[] {eventToBroadcast} );
                }
            }
        }
开发者ID:GoonStudios,项目名称:goon-events,代码行数:12,代码来源:EventDispatcher.cs

示例8: SaveEvent

 private async void SaveEvent(Event @event, string streamName)
 {
     var eventDescriptor = new EventDescriptor(Guid.NewGuid(), @event.GetType().Name, @event);
     var serializedEvent = JsonConvert.SerializeObject(new EventDescriptor[] { eventDescriptor });
     
     using (var client = new HttpClient())
     {
         client.BaseAddress = new Uri("http://localhost:2113/streams/");
         var response = await client.PostAsync(streamName, new StringContent(serializedEvent, Encoding.UTF8, "application/vnd.eventstore.events+json"));
         
         _logger.LogInformation(string.Format("Saving event {0} to stream resulted with {1}", eventDescriptor.EventType, response.StatusCode));
     }
 }
开发者ID:dmusial,项目名称:StackLite,代码行数:13,代码来源:EventStore.cs

示例9: foreach

        public ProjectorInfo[] this[Event @event]
        {
            get
            {
                var eventType = @event.GetType();

                if (!projectorsForEvent.ContainsKey(eventType))
                {
                    foreach (
                        var assembly in
                            AppDomain.CurrentDomain.GetAssemblies().Where(assembly => !projectorsForAssembly.ContainsKey(assembly)))
                    {
                        projectorsForAssembly[assembly] =
                            assembly
                                .GetTypes()
                                .Where(type => type.IsClass)
                                .Where(possibleProjector => typeof (Project).IsAssignableFrom(possibleProjector))
                                .ToArray();
                    }

                    projectorsForEvent[eventType] =
                        projectorsForAssembly
                            .SelectMany(_ => _.Value)
                            .Select(
                                possibleProjectorType =>
                                new
                                    {
                                        PossibleProjectorType = possibleProjectorType,
                                        Projectors =
                                            possibleProjectorType
                                                .GetInterfaces()
                                                .Where(iface => typeof (Project).IsAssignableFrom(iface))
                                                .Where(projector => projector != typeof (Project))
                                                .Where(projector => projector.GetGenericArguments()[0].IsAssignableFrom(eventType))
                                    })
                            .Where(possibleProjectors => possibleProjectors.Projectors.Any())
                            .SelectMany(
                                possibleProjectors => possibleProjectors.Projectors,
                                (possibleProjectors, projector) =>
                                new ProjectorInfo(
                                    projector.GetGenericArguments()[0],
                                    (Project) Activator.CreateInstance(possibleProjectors.PossibleProjectorType)))
                            .ToArray();
                }

                return projectorsForEvent[eventType];
            }
        }
开发者ID:AndyHitchman,项目名称:BlastTrack,代码行数:48,代码来源:ProjectorMap.cs

示例10: count

        private void count(Event evnt)
        {
            String name = evnt.GetType().FullName;
            object curr;

            if (!counts.TryGetValue(name, out curr))
            {
                curr = 0;
            }
            counts[name] = ((int) curr) + 1;
        }
开发者ID:vodkhang,项目名称:RoboCode-Robots,代码行数:11,代码来源:JuniorEvents.cs

示例11:

 /// <summary>
 /// Sends an asynchronous event to a machine.
 /// </summary>
 /// <param name="target">Target machine id</param>
 /// <param name="e">Event</param>
 void IRemoteCommunication.SendEvent(MachineId target, Event e)
 {
     Output.Print("Received sent event {0}", e.GetType());
     PSharpRuntime.SendEvent(target, e);
 }
开发者ID:jerickmsft,项目名称:PSharp,代码行数:10,代码来源:RemoteRequestListener.cs

示例12: registerNamedEvent

 private void registerNamedEvent(Event e)
 {
     if (!HiddenAccessN.isCriticalEvent(e))
     {
         HiddenAccessN.setDefaultPriority(e);
     }
     Type type = e.GetType();
     namedEvents.Add(type.FullName, e);
     namedEvents.Add(type.Name, e);
 }
开发者ID:jccjames422,项目名称:SRE-RoboCode,代码行数:10,代码来源:EventManager.cs

示例13: registerEventNames

        /// <summary>
        /// Registers the full and simple class name of the specified event and sets the default
	    /// priority of the event class.
        /// </summary>
        /// <param name="evnt">an event belonging to the event class to register the class name for etc.</param>
        private void registerEventNames(Event evnt)
        {
            if (!HiddenAccessN.IsCriticalEvent(evnt))
            {
                HiddenAccessN.SetDefaultPriority(evnt);
            }
            Type type = evnt.GetType();
            eventNames.Add(type.FullName, evnt); // full name with package name
            eventNames.Add(type.Name, evnt); // only the class name
        }
开发者ID:Chainie,项目名称:robocode,代码行数:15,代码来源:EventManager.cs

示例14: Dispatch

        /// <summary>
        /// Dispatches an event for a robot.
        /// </summary>
        /// <remarks>
        /// Too old events will not be dispatched and a critical event is always dispatched.
        /// </remarks>
        /// <param name="evnt">is the event to dispatch to the robot.</param>
        private void Dispatch(Event evnt)
        {
            if (robot != null && evnt != null)
            {
                try
                {
                    // skip too old events
                    if ((evnt.Time > Time - MAX_EVENT_STACK) || HiddenAccessN.IsCriticalEvent(evnt))
                    {
                        HiddenAccessN.Dispatch(evnt, robot, robotProxy.getStatics(), robotProxy.getGraphicsImpl());
                    }
                }
// fnl: EventInterruptedException should go to the ProcessEvents() method
//              catch (EventInterruptedException ignore)
//              {
//              }
                catch (Exception ex)
                {
                    if (ex is SecurityException)
                    {
                        robotProxy.punishSecurityViolation(robotProxy.getStatics().getName() + " " + ex.Message);
                    }
                    else if (ex.InnerException is SecurityException)
                    {
                        robotProxy.punishSecurityViolation(robotProxy.getStatics().getName() + " " + ex.InnerException + ": " + ex.Message);
                    }
                    else if (!(ex is AbortedException || ex is DeathException || ex is DisabledException || ex is WinException))
                    {
                        robotProxy.println("SYSTEM: Exception occurred on " + evnt.GetType().Name);
                        robotProxy.GetOut().WriteLine(ex.StackTrace);
                    }
                    throw;
                }
            }
        }
开发者ID:Chainie,项目名称:robocode,代码行数:42,代码来源:EventManager.cs

示例15: RouteEventToCommand

        //---------------------------------------------------------------------
        //  Internal
        //---------------------------------------------------------------------
        /**
         * Event Handler
         *
         * @param event The <code>Event</code>
         * @param commandClass The Type to construct and execute
         * @param oneshot Should this command mapping be removed after execution?
         */
        protected void RouteEventToCommand( Event e, Type commandClass, bool oneshot, Type originalEventClass )
        {
            if( !originalEventClass.IsInstanceOfType(e) )
                return;

            Type eventClass = e.GetType(); //Warning was object( e ).constructor

            //TODO We will have to use the Unity lifetimemanager here
            injector.MapValue( eventClass, e );
            object command = injector.Instantiate( commandClass );
            injector.Unmap( eventClass );

            MethodInfo methodInfo = null;
            try
            {
                methodInfo = commandClass.GetMethod("Execute");
            }
            catch( AmbiguousMatchException )
            {
                throw( new Exception("AmbiguousMatchException was thrown when trying to access to the Execute method") );
            }
            catch( ArgumentNullException )
            {
                throw( new Exception("ArgumentNullException was thrown when trying to access to the Execute method") );
            }

            methodInfo.Invoke(command,null);

            if( oneshot )
            {
                UnmapEvent( e.Type, commandClass, originalEventClass );
            }
        }
开发者ID:tekool,项目名称:silverlight-robotlegs-framework,代码行数:43,代码来源:CommandMap.cs


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