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


C# EventData类代码示例

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


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

示例1: OnItemExit

 /// <summary>
 /// Notifies peer about item exited area.
 /// </summary>
 public override void OnItemExit(Item item)
 {
     base.OnItemExit(item);
     var unsubscribeEvent = new ItemUnsubscribed { ItemId = item.Id, InterestAreaId = this.Id };
     var eventData = new EventData((byte)EventCode.ItemUnsubscribed, unsubscribeEvent);
     this.peer.SendEvent(eventData, new SendParameters { ChannelId = Settings.ItemEventChannel });
 }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:10,代码来源:ClientInterestArea.cs

示例2: WriteJsonEntry

        private void WriteJsonEntry(EventData e)
        {
            _writer.WriteStartObject();

            _writer.WritePropertyName("index");

            // Write the batch "index" operation header
            _writer.WriteStartObject();
            // ES index names must be lower case and cannot contain whitespace or any of the following characters \/*?"<>|,
            WriteValue("_index", this.GetIndexName(e.EnqueuedTimeUtc));
            WriteValue("_type", _entryType);

            _writer.WriteEndObject();
            _writer.WriteEndObject();
            _writer.WriteRaw("\n");  //ES requires this \n separator

            var payload = JObject.Parse(Encoding.UTF8.GetString(e.GetBytes()));

            foreach (var property in e.Properties)
            {
                payload.Add("Properties-" + property.Key, new JValue(property.Value));
            }

            _writer.WriteRaw(payload.ToString(Formatting.None));
            
            _writer.WriteRaw("\n");
        }
开发者ID:carloserodriguez2000,项目名称:iot-journey,代码行数:27,代码来源:ElasticSearchEventDataSerializer.cs

示例3: MyEventHandler

        //This method is used to handle the event when it's raised
        void MyEventHandler(Object sender, EventData e)
        {
            // Wait until safe to run
            mut.WaitOne();
            // Write to console
            Console.WriteLine(Name.PadRight(15) + e.stockName.PadRight(15) +
                              e.currentValue.ToString().PadRight(15) +
                              e.numOfChange.ToString());
            // This text is added only once to the file.
            if (!File.Exists(path))
            {
                // Create a file to write to.
                using (StreamWriter sw = File.CreateText(path))
                {
                    //Write the table header to the file
                    sw.WriteLine("Broker".PadRight(15) + "Stock".PadRight(15) +
                                 "Value".PadRight(15) + "Changes".PadRight(15) +
                                 "\r\n");
                }
            }

            // This text is always added, making the file longer over time
            // if it is not deleted.
            using (StreamWriter sw = File.AppendText(path))
            {
                //Write the event data to the file
                sw.WriteLine(Name.PadRight(15) + e.stockName.PadRight(15) +
                              e.currentValue.ToString().PadRight(15) +
                              e.numOfChange.ToString());
            }
            // Release mutex
            mut.ReleaseMutex();
        }
开发者ID:noel09,项目名称:CECS475-Lab03,代码行数:34,代码来源:StockBroker.cs

示例4: OnEvent

 public void OnEvent(EventData eData)
 {
     if (eData.eventType == "EQUIPPED_UPDATE") {
         // Update equipped items dictionary
         equippedItems = ClientAPI.ScriptObject.GetComponent<Inventory>().EquippedItems;
     }
 }
开发者ID:BladeFight,项目名称:EgionOnline,代码行数:7,代码来源:Character.cs

示例5: WorldEnterEventArgs

 /// <summary>
 /// 类型:方法
 /// 名称:EnterWorldEventArgs
 /// 作者:taixihuase
 /// 作用:用任意角色进入场景所感兴趣的数据构造事件数据
 /// 编写日期:2015/7/22
 /// </summary>
 /// <param name="eventData"></param>
 public WorldEnterEventArgs(EventData eventData)
 {
     Character character = (Character)
         Serialization.Deserialize(eventData.Parameters[(byte) ParameterCode.WorldEnter]);
     AnyCharacter = character;
     MyCharacterPosition = null;
 }
开发者ID:taixihuase,项目名称:SiegeOnline,代码行数:15,代码来源:WorldEnterEventArgs.cs

示例6: XmlDocument

        IList<IEvent> IEventBuilder.Build(string xml)
        {
            IList<IEvent> events = new List<IEvent>();

            if (String.IsNullOrEmpty(xml))
            {
                return events;
            }

            xml = xml.EscapeWhiteSpace();

            //get out quick if no data
            if (REGEX.IsMatch(xml))
            {
                return events;
            }

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            XmlNodeList eventNodes = doc.SelectNodes(String.Format("//{0}", EVENT));

            if (eventNodes != null)
            {
                foreach (XmlNode eventNode in eventNodes)
                {
                    IEvent e = new EventData(eventNode);
                    events.Add(e);
                }
            }

            return events;
        }
开发者ID:mattapayne,项目名称:Jambase4Net,代码行数:33,代码来源:DefaultEventBuilder.cs

示例7: OnBroadcastMessage

 private void OnBroadcastMessage(ChatPeer peer, EventData @event, SendParameters sendParameters)
 {
     if (peer != this)
     {
         this.SendEvent(@event, sendParameters);
     }
 }
开发者ID:rkdrnf,项目名称:photonserver,代码行数:7,代码来源:ChatPeer.cs

示例8: SendBatch

        public async Task SendBatch()
        {
            var msgs = new EventData[] { new EventData(Guid.NewGuid().ToByteArray()), new EventData(Guid.NewGuid().ToByteArray()), new EventData(Guid.NewGuid().ToByteArray()), new EventData(Guid.NewGuid().ToByteArray()) };

            var bq = new HubClient(EventHubClient.CreateFromConnectionString(connection, this.name));
            await bq.Send(msgs);
        }
开发者ID:modulexcite,项目名称:King.Service.ServiceBus,代码行数:7,代码来源:HubClientTests.cs

示例9: OnEvent

 public override void OnEvent(EventData eventData) {
     SubCode subcode = ParameterTool.GetParameters<SubCode>(eventData.Parameters, ParameterCode.SubCode, false);
     switch(subcode)
     {
         case SubCode.GetTeam:
             List<Role> list = ParameterTool.GetParameters<List<Role>>(eventData.Parameters, ParameterCode.RoleList);
             int masterRoleID = ParameterTool.GetParameters<int>(eventData.Parameters, ParameterCode.MasterRoleID, false);       
              //组队成功
             if (OnGetTeam != null)
                 OnGetTeam(list, masterRoleID);
             break;
         case SubCode.AsyncPostionAndEularAngler:
             int roleid = ParameterTool.GetParameters<int>(eventData.Parameters, ParameterCode.RoleID,false);
             Vector3 pos = ParameterTool.GetParameters<Vector3Obj>(eventData.Parameters, ParameterCode.Postion).ToVector3();
             Vector3 eularAnglers = ParameterTool.GetParameters<Vector3Obj>(eventData.Parameters, ParameterCode.EulerAnglers).ToVector3();
             if (OnAsyncPostionAndRotation != null)
                 OnAsyncPostionAndRotation(roleid, pos, eularAnglers);
             break;
         case SubCode.AsyncPlayerMoveAnimation:
             int roleid2 = ParameterTool.GetParameters<int>(eventData.Parameters, ParameterCode.RoleID, false);
             PlayerMoveAnimationModel model = ParameterTool.GetParameters<PlayerMoveAnimationModel>(eventData.Parameters, ParameterCode.PlayerMoveAnimationModel);
             if (OnAsyncPlayerMoveAnimation != null)
                 OnAsyncPlayerMoveAnimation(roleid2, model);
             break;
         case SubCode.SyncPlayerAnimation:
             int roleid3 = ParameterTool.GetParameters<int>(eventData.Parameters, ParameterCode.RoleID, false);
             PlayerAnimationModel animationModel = ParameterTool.GetParameters<PlayerAnimationModel>(eventData.Parameters, ParameterCode.PlayerAnimationModel);
             if(OnSyncPlayerAnimation!=null)
             {
                 OnSyncPlayerAnimation(roleid3, animationModel);
             }
             break;
     }
 }
开发者ID:1510649869,项目名称:ARPG_project,代码行数:34,代码来源:BattleController.cs

示例10: EventDataEqualityTest

        public void EventDataEqualityTest()
        {
            var dateTimeOffset = DateTimeOffset.Now;

            var left = new EventData
            {
                Name = "name",
                Data = "somedata",
                Ttl = 50,
                PublishedAt = dateTimeOffset,
                DeviceId = "coreid"
            };

            var right = new EventData
            {
                Name = "name",
                Data = "somedata",
                Ttl = 50,
                PublishedAt = dateTimeOffset,
                DeviceId = "coreid"
            };

            Assert.AreEqual(left.GetHashCode(), right.GetHashCode());
            Assert.AreEqual(left, right);
        }
开发者ID:AppSpaceIT,项目名称:ParticleIoNet,代码行数:25,代码来源:EventDataTests.cs

示例11: Save

        public void Save(MainViewModel viewModel)
        {
            GestSpaceData space = new GestSpaceData();
            foreach(var tileVm in viewModel.Tiles.Where(t => !t.IsUnused))
            {
                var tile = new TileData();
                space.Tiles.Add(tile);
                if(!tileVm.TakeSuggestedName)
                {
                    tile.ForcedName = tileVm.Description;
                }
                tile.X = (int)tileVm.Position.X;
                tile.Y = (int)tileVm.Position.Y;
                if(tileVm.SelectedPresenterTemplate != null)
                    tile.PresenterTemplate = tileVm.SelectedPresenterTemplate.Description;
                if(tileVm.SelectedGestureTemplate != null)
                    tile.GestureTemplate = tileVm.SelectedGestureTemplate.Name;

                tile.Program = tileVm.FastContext;
                foreach(var evtVm in tileVm.Events)
                {
                    var evt = new EventData();
                    tile.Events.Add(evt);
                    evt.Name = evtVm.Name;
                    if(evtVm.Command != null)
                        evt.Command = evtVm.Command.Script;
                }
            }
            if(viewModel.CurrentTile != null)
            {
                space.LastX = (int)viewModel.CurrentTile.Position.X;
                space.LastY = (int)viewModel.CurrentTile.Position.Y;
            }
            Save(space);
        }
开发者ID:NicolasDorier,项目名称:GestSpace,代码行数:35,代码来源:GestSpaceRepository.cs

示例12: sendMessage

        static bool sendMessage(string deviceLocation, string dateTime)
        {
            // build a connection string
            string connectionString = String.Format("Endpoint=sb://stardemo.servicebus.windows.net/;SharedAccessKeyName=WebAppWrite;SharedAccessKey", Environment.GetEnvironmentVariable("EventHubKey"));
            string name = "stardemo";

            // set up the event-hub communicator
            EventHubClient myEventHub = EventHubClient.CreateFromConnectionString(connectionString, name);

            // build the message and encode for sending
            string message = String.Format("{location:{0},datetime:{1}}", deviceLocation,dateTime);
            EventData myEventData = new EventData(Encoding.UTF8.GetBytes(message));

            // try and send the message
            bool success = false;
            try
            {
                myEventHub.Send(myEventData);
                success = true; // hooray!
            }
            catch (Exception)
            {
                // that didn't work, now what?
                throw;
            }
            return success;
        }
开发者ID:jessevl,项目名称:RSM-STAR-Demo,代码行数:27,代码来源:EventHub.cs

示例13: Run

    public void Run() {
      lock (this.m_instanceLock) {
        EventData data = new EventData();

        this.m_runningThread = Thread.CurrentThread;

        while (!this.m_isShuttingDown) {
          lock (this.m_events) {
            LinkedListNode<EventData> firstItem = this.m_events.First;
            if (firstItem != null) {
              data = firstItem.Value;
              this.m_events.RemoveFirst();
            } else {
              data.Function = null;
              data.Parameters = null;
            }
          }

          if (data.Function == null) {
            this.m_eventsWaiting.WaitOne();
          } else {
            data.Function.DynamicInvoke(data.Parameters);
            if (data.Executed != null) {
              data.Executed.Set();
            }
          }
        }

        this.m_shutdownCompleteEvent.Set();
      }
    }
开发者ID:huyettoc,项目名称:duycm-workstation,代码行数:31,代码来源:EventQueue.cs

示例14: OnEvent

    public override void OnEvent(EventData eventData)
    {
        SubCode subcode = ParameterTool.GetSubCode(eventData.Parameters);
        switch (subcode)
        {
            case SubCode.CreateEnemy:
                CreateEnemyModel model = ParameterTool.GetParameter<CreateEnemyModel>(eventData.Parameters,
                    ParameterCode.CreateEnemyModel);
                if (OnCreateEnemy != null)
                {
                    OnCreateEnemy(model);
                }
                break;
            case SubCode.SyncPositionAndRotation:
                EnemyPositionModel model1 = ParameterTool.GetParameter<EnemyPositionModel>(eventData.Parameters,
                    ParameterCode.EnemyPositionModel);
                if (OnSyncEnemyPositionAndRotation != null)
                {
                    OnSyncEnemyPositionAndRotation(model1);
                }
                break;

            case SubCode.SyncAnimation:
                EnemyAnimationModel model2 = ParameterTool.GetParameter<EnemyAnimationModel>(eventData.Parameters,ParameterCode.EnemyAnimationModel);
                if (OnSyncEnemyAnimation != null)
                {
                    OnSyncEnemyAnimation(model2);
                }
                break;
        }
    }
开发者ID:vin120,项目名称:TaiDou,代码行数:31,代码来源:EnemyController.cs

示例15: SendDeviceEventStream

 private void SendDeviceEventStream(EventHubClient eventHubClient)
 {
     var allEvents = new List<EventData>();
     for (int i = 0; i < DeviceSendingDetails.NumberOfDevices; i++)
     {
         string deviceName = "device" + i;
         var rand = new Random();
         // set up the modifier to enable 
         float modifier = 1.0F;
         if (DeviceSendingDetails.FailureConditions.Any(device => device.FailedDeviceId == i))
         {
             var deviceDetails = DeviceSendingDetails.FailureConditions.First(device => device.FailedDeviceId == i);
             modifier = modifier += deviceDetails.FailedDeviceGradient;
         }
         var deviceValue = rand.Next((int) ((DeviceSendingDetails.TemperatureMin * modifier)*100),
             (int) ((DeviceSendingDetails.TemperatureMax * modifier)*100));
         var deviceData = new DeviceData()
         {
             deviceid = deviceName,
             temperature = (deviceValue/100F),
             timestamp = DateTime.UtcNow
         };
         var jsonDeviceDetail = JsonConvert.SerializeObject(deviceData);
         var encodedPayload = Encoding.UTF8.GetBytes(jsonDeviceDetail);
         var eventData = new EventData(encodedPayload)
         {
             PartitionKey = "devices"
         };
         allEvents.Add(eventData);
     }
     eventHubClient.SendBatch(allEvents);
 }
开发者ID:Mecabot,项目名称:iot-labs,代码行数:32,代码来源:MessageGenerator.cs


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