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


C# IEvent类代码示例

本文整理汇总了C#中IEvent的典型用法代码示例。如果您正苦于以下问题:C# IEvent类的具体用法?C# IEvent怎么用?C# IEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: InvokeHandlers

        private void InvokeHandlers(IEvent @event, IEnumerable<HandlerMethod> handlers)
        {
            foreach (var method in handlers)
            {
                object handler;

                try
                {
                    handler = HandlerActivator.CreateInstance(method.ReflectedType);
                }
                catch (Exception ex)
                {
                    throw new EventHandlerException("Fail to activate event handler: " + method.ReflectedType + ". See inner exception for details.", ex);
                }

                try
                {
                    method.Invoke(handler, @event);
                }
                catch (Exception ex)
                {
                    throw new EventHandlerException("Fail to execute event handler: " + method.ReflectedType + ". See inner exception for details.", ex);
                }
            }
        }
开发者ID:mouhong,项目名称:Taro,代码行数:25,代码来源:InProcessEventTransport.cs

示例2: FireEvent

        public void FireEvent(
			IEvent @event)
        {
            string namespaceUri = @event.NamespaceUri;
            string eventType = @event.Type;
            for (int i = 0; i < count; i++)
            {
            // Check if the entry was added during this phase
            if (entries[i].Locked)
              continue;

                string entryNamespaceUri = entries[i].NamespaceUri;
                string entryEventType = entries[i].Type;

                if (entryNamespaceUri != null && namespaceUri != null)
                {
                    if (entryNamespaceUri != namespaceUri)
                    {
                        continue;
                    }
                }

                if (entryEventType != eventType)
                {
                    continue;
                }

                entries[i].Listener(@event);
            }
        }
开发者ID:codebutler,项目名称:savagesvg,代码行数:30,代码来源:EventListenerMap.cs

示例3: EmulatorQuit

 public void EmulatorQuit(IEvent e)
 {
     foreach (var a in _gameEndedActions)
     {
         a.Invoke();
     }
 }
开发者ID:PhilipBrockmeyer,项目名称:Wren,代码行数:7,代码来源:GameEventAggregator.cs

示例4: TryParse

        /// <summary>
        /// Tries to parse the given data to the target <see cref="IEvent"/>.
        /// </summary>
        /// <param name="eventParams">List of string-parameters to parse.</param>
        /// <param name="target">Target instance to parse the data to.</param>
        /// <returns><c>true</c> if the parsing was succesful, otherwise <c>false</c> is returned.</returns>
        public bool TryParse(List<string> eventParams, IEvent target)
        {
            if (eventParams.Count < 4)
            {
                return false;
            }

            if (string.IsNullOrEmpty(eventParams[0]))
            {
                return false;
            }

            float posX, posY, posZ;
            if( !float.TryParse(eventParams[1], out posX) ||
                !float.TryParse(eventParams[2], out posY) ||
                !float.TryParse(eventParams[3], out posZ) )
            {
                return false;
            }

            if (!target.HasProperty("EntityName") || !target.HasProperty("Target"))
            {
                return false;
            }

            UnityEngine.Vector3 targetPosition = new UnityEngine.Vector3();
            targetPosition.x = posX;
            targetPosition.y = posY;
            targetPosition.z = posZ;

            target.SetProperty("EntityName", eventParams[0]);
            target.SetProperty("Target", targetPosition);
            return true;
        }
开发者ID:haleox,项目名称:mortar,代码行数:40,代码来源:EntityNameVector3Parser.cs

示例5: DefaultEvent

		/// <summary>
		/// Copy constructor
		/// </summary>
		protected DefaultEvent(IEvent ev)
			: base(ev)
		{
			this.addAccessor = ev.AddAccessor;
			this.removeAccessor = ev.RemoveAccessor;
			this.invokeAccessor = ev.InvokeAccessor;
		}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:10,代码来源:DefaultEvent.cs

示例6: Publish

 public void Publish(IEvent eventMessage)
 {
     foreach (var bus in _wrappedBuses)
     {
         bus.Publish(eventMessage);
     }
 }
开发者ID:HAXEN,项目名称:ncqrs,代码行数:7,代码来源:CompositeEventBus.cs

示例7: SendEventToClient

    /// <summary>
    /// This method will handle sending an event to a client.
    /// </summary>
    public static void SendEventToClient(string ipAddress, int port, IEvent evnt)
    {
      try
      {
        var client = new TcpClient(ipAddress, port);

        // TODO: Serialize the event into json...
        string json = JsonConvert.SerializeObject(evnt);
        byte[] data = System.Text.Encoding.Unicode.GetBytes(json);

        // Get a client stream for reading and writing.
        var stream = client.GetStream();
        stream.Write(data, 0, data.Length);

        Console.WriteLine("Sent: {0}", json);

        // Close everything.
        stream.Close();
        client.Close();
      }
      catch (ArgumentNullException e)
      {
        Console.WriteLine("ArgumentNullException: {0}", e);
      }
      catch (SocketException e)
      {
        Console.WriteLine("SocketException: {0}", e);
      }
    }
开发者ID:pcewing,项目名称:ChatApplication,代码行数:32,代码来源:EventManager.cs

示例8:

 void IEventHelpers.RegisterSocketRead(IEvent e, BufferedSocket socket, IEventHandler protocol,
                                       ReadFunction callback)
 {
     //Contract.Requires(socket != null);
     Contract.Requires(protocol != null);
     Contract.Requires(callback != null);
 }
开发者ID:splitice,项目名称:EventCore,代码行数:7,代码来源:IEventHelpers.cs

示例9: EventMessage

        public EventMessage(IEvent source)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            sourceMeta = new Dictionary<string, object>();
            eventMeta = new Dictionary<string, object>();

            var eventSource = source.EventSource;
            while (eventSource != null) {
                foreach (var meta in source.EventSource.Metadata) {
                    sourceMeta[meta.Key] = meta.Value;
                }

                eventSource = eventSource.ParentSource;
            }

            if (source.EventData != null) {
                foreach (var pair in source.EventData) {
                    eventMeta[pair.Key] = pair.Value;
                }
            }

            TimeStamp = source.TimeStamp;
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:25,代码来源:EventMessage.cs

示例10: run

 public void run(IEvent e)
 {
     BoardMovedNotify notify = new BoardMovedNotify();
     this.boardMachine.fireStateChangedNotification(notify);
     LOG.Info(NAME);
     this.boardMachine.consumeEvent(new BoardReadyEvent());
 }
开发者ID:hoangchunghien,项目名称:ChineseChessLearning,代码行数:7,代码来源:BoardMovedState.cs

示例11: CreateEvent

        public static bool CreateEvent(IEvent thisEvent)
        {
            if (Connect())
            {
                try
                {
                    SqlCommand Command = Connection.CreateCommand();
                    Command.CommandType = CommandType.StoredProcedure;
                    Command.CommandText = "fif_event_create";

                    Command.Parameters.AddWithValue("name", thisEvent.Name);
                    Command.Parameters.AddWithValue("price", thisEvent.Price);
                    Command.Parameters.AddWithValue("description", thisEvent.Description);
                    Command.Parameters.AddWithValue("start_period", thisEvent.StartPeriod);
                    Command.Parameters.AddWithValue("end_period", thisEvent.EndPeriod);
                    Command.Parameters.AddWithValue("max_number_of_participants", thisEvent.MaxNumberOfParticipants);

                    Command.Parameters.Add("@activity_id", SqlDbType.Int, 0, "activity_id");
                    Command.Parameters["@activity_id"].Direction = ParameterDirection.Output;

                    Command.ExecuteNonQuery();

                    thisEvent.ActivityId = int.Parse(Command.Parameters["@activity_id"].Value.ToString());

                    Disconnect();
                    return true;
                }
                catch
                {
                    Disconnect();
                    return false;
                }
            }
            return false;
        }
开发者ID:TheMrCaira,项目名称:FjordagerTaekwando,代码行数:35,代码来源:EventPersistence2.cs

示例12: LoadIEvent

        private void LoadIEvent()
        {
            if (_ievent == null)
            {
                if (this.ScheduleType == null)
                {
                    Logger.LogInfo("计划任务没有定义其 type 属性");
                    
                }

                Type type = Type.GetType(this.ScheduleType);
                if (type == null)
                {
                    Logger.LogInfo(string.Format("计划任务 {0} 无法被正确识别", this.ScheduleType));
                }
                else
                {
                    _ievent = (IEvent)Activator.CreateInstance(type);
                    if (_ievent == null)
                    {
                        Logger.LogInfo(string.Format("计划任务 {0} 未能正确加载", this.ScheduleType));
                    }
                }
            }
        }
开发者ID:iraychen,项目名称:LCLFramework,代码行数:25,代码来源:Event.cs

示例13: EventToString

        /// <summary>
        /// Converts event to <c>string</c> representation.
        /// </summary>
        /// <param name="Event">Event to be converted to <c>string</c></param>
        /// <returns>Returns resulting <c>string</c>.</returns>
        public static string EventToString( IEvent Event )
        {
            StringBuilder builder = new StringBuilder( 200 );
            builder.Append( "[Type=" );
            builder.Append( Event.Type.ToString() );

            if( Event.Description!=null )
            {
                builder.Append( "][Message=" );
                builder.Append( Event.Description );
            }

            if( Event.Sender != null )
            {
                builder.Append( "][ModelID=" );
                builder.Append( ((ILinkableComponent) Event.Sender).ModelID );
            }

            if( Event.SimulationTime != null )
            {
                builder.Append( "][SimTime=" );
                builder.Append( CalendarConverter.ModifiedJulian2Gregorian(Event.SimulationTime.ModifiedJulianDay).ToString() );
            }

            builder.Append( ']' );

            return( builder.ToString() );
        }
开发者ID:KangChaofan,项目名称:OOC,代码行数:33,代码来源:Utils.cs

示例14:

 /// <summary>
 /// Listen for VirtualBox events.
 /// </summary>
 /// <param name="aEvent">VirtualBox event</param>
 void IEventListener.HandleEvent(IEvent aEvent)
 {
     if (aEvent.Type == VBoxEventType.VBoxEventType_OnMachineStateChanged)
     {
         vboxServer.UpdateServersState();
     }
 }
开发者ID:forrest79,项目名称:devel79tray,代码行数:11,代码来源:VirtualBoxServer.cs

示例15: GetEventDataAsString

        /// <summary>
        /// Gets a string of all data properties of the passed <see cref="IEvent"/>.
        /// Format-Example: Name0: Value0, ..., NameN: ValueN
        /// </summary>
        /// <param name="e"><see cref="IEvent"/> to create data string from.</param>
        /// <returns>String representing the <see cref="IEvent"/> data.</returns>
        public static string GetEventDataAsString(IEvent e)
        {
            string data = "";

            if (e != null)
            {
                int i = 0;
                foreach (PropertyInfo property in e.GetType().GetProperties())
                {
                    if (GetNamesOfProperties().Contains(property.Name))
                    {
                        continue;
                    }

                    if (i > 0)
                    {
                        data += ", ";
                    }
                    data += string.Format("{0}: {1}", property.Name, property.GetValue(e, null));
                    i++;
                }
            }

            return data;
        }
开发者ID:haleox,项目名称:mortar,代码行数:31,代码来源:Event.cs


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