/// <summary> /// 解析Event /// </summary> /// <param name="eventName">even名称</param> /// <param name="logs">对应logs</param> /// <returns>返回解析后的Event数据</returns> public List <EventLog <List <ParameterOutput> > > EventDecode(string eventName, BcosFilterLog[] logs) { var setEventAbi = contractAbi.Events.FirstOrDefault(e => e.Name == eventName); var list = EventExtensions.DecodeAllEventsDefaultTopics(setEventAbi, JArray.FromObject(logs)); return(list); }
public void TryInvokeTests() { bool result = true; result = EventExtensions.TryInvoke <EventArgs <dataClass> > (null, this, new EventArgs <dataClass>(Invoke1Value)); Assert.IsFalse(result); }
private static Event GetBasicSeriesEventDataWithClinetId(IStorePropertyBag propertyBag, IStorageEntitySetScope <IStoreSession> scope) { Event basicSeriesEventData = EventExtensions.GetBasicSeriesEventData(propertyBag, scope); basicSeriesEventData.ClientId = propertyBag.GetValueOrDefault <string>(CalendarItemBaseSchema.EventClientId, null); return(basicSeriesEventData); }
public void Invoke1Tests() { EventExtensions.Invoke <dataClass> ( new EventHandler <EventArgs <dataClass> > ( (object sender, EventArgs <dataClass> e) => ((dataClass)e.Value).Fired = true), this, Invoke1Value); Assert.IsTrue(Invoke1Value.Fired); }
private Event GetOccurrenceWithStartAndEnd(IStorePropertyBag propertyBag) { Event basicSeriesEventData = EventExtensions.GetBasicSeriesEventData(propertyBag, this.Scope); basicSeriesEventData.Start = propertyBag.GetValueOrDefault <ExDateTime>(CalendarItemInstanceSchema.StartTime, ExDateTime.MinValue); basicSeriesEventData.End = propertyBag.GetValueOrDefault <ExDateTime>(CalendarItemInstanceSchema.EndTime, ExDateTime.MaxValue); return(basicSeriesEventData); }
private Event GetInstancePropagationData(IStorePropertyBag propertyBag) { Event basicSeriesEventData = EventExtensions.GetBasicSeriesEventData(propertyBag, this.Scope); IActionPropagationState actionPropagationState = basicSeriesEventData; actionPropagationState.LastExecutedAction = propertyBag.GetValueOrDefault <Guid?>(CalendarItemSchema.LastExecutedCalendarInteropAction, null); return(basicSeriesEventData); }
protected override void Dispose(bool disposing) { if (!offlineMode) { EventExtensions.UnsubscribeEvents(Program.TasClient, this); } base.Dispose(disposing); }
public static void RaiseCollectionChanged(this INotifyCollectionChanged sender, NotifyCollectionChangedEventArgs args) { if (sender == null) { return; } EventExtensions.RaiseEvent(sender, nameof(INotifyCollectionChanged.CollectionChanged), args); }
public static EventData Create(Guid eventId, object evnt, IDictionary <string, object> headers) { var data = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(evnt, SerializerSettings)); var metadata = AddEventClrTypeHeaderAndSerializeMetadata(evnt, headers); var typeName = EventExtensions.UnifiedEventName(evnt.GetType()); return(new EventData(eventId, typeName, true, data, metadata)); }
public void TryInvoke2Tests() { bool result = false; result = EventExtensions.TryInvoke <EventArgs <dataClass> > (new EventHandler <EventArgs <dataClass> > ( (object sender, EventArgs <dataClass> e) => ((dataClass)e.Value).Fired = true), this, new EventArgs <dataClass>(TryInvoke2Value)); Assert.IsTrue(result); Assert.IsTrue(TryInvoke2Value.Fired); }
private byte[] ConvertToBytes(EventDocumentDto document, long id) { var meta = new EventMeta { Version = document.Version, Timestamp = document.Timestamp, FlowId = document.FlowId }; using var baseBytes = EventExtensions.ConvertToBytes(meta); var transUnit = new EventTransUnit(document.Name, id, baseBytes.AsSpan(), Encoding.UTF8.GetBytes(document.Data)); using var buffer = EventConverter.ConvertToBytes(transUnit); return(buffer.ToArray()); }
private Event GetBasicEventData(IStorePropertyBag propertyBag) { Event basicSeriesEventData = EventExtensions.GetBasicSeriesEventData(propertyBag, this.Scope); byte[] valueOrDefault = propertyBag.GetValueOrDefault <byte[]>(CalendarItemBaseSchema.GlobalObjectId, null); if (valueOrDefault != null) { IEventInternal eventInternal = basicSeriesEventData; eventInternal.GlobalObjectId = new GlobalObjectId(valueOrDefault).ToString(); } return(basicSeriesEventData); }
private void Initialize() { Gpus = new MtObservableCollection <Gpu>(); for (var i = 0; i < GetTotalNumberOfGpus(); i++) { var id = i; id++; Gpus.Add(new Gpu { Identifier = id }); } var gpuVisibility = new[] { UserSettings.GlobalSettings.VisibilitySystemGpuTemp, UserSettings.GlobalSettings.VisibilitySystemGpuLoad }; _computer = new Computer { CPUEnabled = UserSettings.GlobalSettings.VisibilitySystemCpuTemp, GPUEnabled = BooleanExtensions.ExceedsThreshold(0, gpuVisibility) }; _computer.Open(); // Cpu timer var timerCpu = new Timer { Interval = UserSettings.GlobalSettings.PollingRateCpu }; timerCpu.Elapsed += timerCpu_Elapsed; timerCpu.Start(); // Ram timer var timerRam = new Timer { Interval = UserSettings.GlobalSettings.PollingRateRam }; timerRam.Elapsed += timerRam_Elapsed; timerRam.Start(); // Temp timer var timerTemp = new Timer { Interval = UserSettings.GlobalSettings.PollingRateTemps }; timerTemp.Elapsed += timerTemp_Elapsed; timerTemp.Start(); // Get the value at init EventExtensions.FireEvent(timerCpu, "onIntervalElapsed", this, null); EventExtensions.FireEvent(timerRam, "onIntervalElapsed", this, null); EventExtensions.FireEvent(timerTemp, "onIntervalElapsed", this, null); }
private void Initialize() { Drives = new MtObservableCollection <Drive>(); var timerDriveInfo = new Timer { Interval = UserSettings.GlobalSettings.PollingRateDrives }; timerDriveInfo.Elapsed += timerDriveInfo_Elapsed; timerDriveInfo.Start(); // Get the value at init EventExtensions.FireEvent(timerDriveInfo, "onIntervalElapsed", this, null); }
private void Initialize() { try { foreach (var ni in NetworkInterface.GetAllNetworkInterfaces().Where(x => x.OperationalStatus.Equals(OperationalStatus.Up)).Where(x => x.NetworkInterfaceType.Equals(NetworkInterfaceType.Wireless80211) || x.NetworkInterfaceType.Equals(NetworkInterfaceType.Ethernet))) { _networkInterfaceName = ni.Description.Replace('(', '[').Replace(')', ']'); } } catch (Exception ex) { Console.WriteLine(ex); } if (string.IsNullOrEmpty(_networkInterfaceName)) { Logger.Write("NetworkTicker() - NetworkInterface.GetAllNetworkInterfaces() - string.IsNullOrEmpty(_networkInterfaceName)", true); } // Traffic timer var timerTraffic = new Timer { Interval = UserSettings.GlobalSettings.PollingRateNetwork }; timerTraffic.Elapsed += timerTraffic_Elapsed; timerTraffic.Start(); // External IP timer var timerExternalIp = new Timer { Interval = UserSettings.GlobalSettings.PollingRateIpExternal }; timerExternalIp.Elapsed += timerExternalIp_Elapsed; timerExternalIp.Start(); // Internal IP timer var timerInternalIp = new Timer { Interval = UserSettings.GlobalSettings.PollingRateIpInternal }; timerInternalIp.Elapsed += timerInternalIp_Elapsed; timerInternalIp.Start(); // Get the values at init EventExtensions.FireEvent(timerTraffic, "onIntervalElapsed", this, null); EventExtensions.FireEvent(timerExternalIp, "onIntervalElapsed", this, null); EventExtensions.FireEvent(timerInternalIp, "onIntervalElapsed", this, null); }
private void Initialize() { var timerNow = new Timer { Interval = UserSettings.GlobalSettings.PollingRateDateTime }; timerNow.Elapsed += timerNow_Elapsed; timerNow.Start(); var timerWeek = new Timer { Interval = UserSettings.GlobalSettings.PollingRateWeek }; timerWeek.Elapsed += timerWeek_Elapsed; timerWeek.Start(); // Get the values at init EventExtensions.FireEvent(timerNow, "onIntervalElapsed", this, null); EventExtensions.FireEvent(timerWeek, "onIntervalElapsed", this, null); }
private Event GetBasicEventDataForRetry(IStorePropertyBag propertyBag) { Event basicSeriesEventData = EventExtensions.GetBasicSeriesEventData(propertyBag, this.Scope); string valueOrDefault = propertyBag.GetValueOrDefault <string>(CalendarItemBaseSchema.EventClientId, null); int valueOrDefault2 = propertyBag.GetValueOrDefault <int>(CalendarItemSchema.InstanceCreationIndex, -1); int valueOrDefault3 = propertyBag.GetValueOrDefault <int>(CalendarItemSeriesSchema.SeriesCreationHash, -1); basicSeriesEventData.ClientId = valueOrDefault; IEventInternal eventInternal = basicSeriesEventData; if (valueOrDefault2 != -1) { eventInternal.InstanceCreationIndex = valueOrDefault2; } if (valueOrDefault3 != -1) { eventInternal.SeriesCreationHash = valueOrDefault3; } return(basicSeriesEventData); }
public string this[string propertyName] { get { string validationResult = null; switch (propertyName) { case nameof(Duration): validationResult = _validateDuration(); break; case nameof(ScheduledTc): validationResult = _validateScheduledTc(); break; case nameof(ScheduledTime): case nameof(ScheduledTimeOfDay): case nameof(ScheduledDate): validationResult = _validateScheduledTime(); break; case nameof(TransitionTime): validationResult = _validateTransitionTime(); break; case nameof(TransitionPauseTime): validationResult = _validateTransitionPauseTime(); break; case nameof(ScheduledDelay): validationResult = _validateScheduledDelay(); break; case nameof(Command): validationResult = EventExtensions.IsValidCommand(_command) ? string.Empty : resources._validate_CommandSyntax; break; } return(validationResult); } }
public ICollection <AggregateEvent <TDomainEvent> > ReadEventsByType <TDomainEvent>() where TDomainEvent : IDomainEvent { var streamName = "$et-" + EventExtensions.UnifiedEventName(typeof(TDomainEvent)); var eventsForAggregate = new List <AggregateEvent <TDomainEvent> >(); StreamEventsSlice currentSlice; var nextSliceStart = 0L; do { currentSlice = connection .ReadStreamEventsForwardAsync(streamName, nextSliceStart, Settings.ReadPageSize, true) .Result; nextSliceStart = currentSlice.NextEventNumber; foreach (var evnt in currentSlice.Events) { var metaData = Serializer.DeserializeMetadata(evnt.Event.Metadata); var e = (TDomainEvent)Serializer.DeserializeEvent(evnt.Event.Metadata, evnt.Event.Data); var k = evnt.Event.EventStreamId; System.Console.WriteLine(k); var aggregateStreamType = metaData[Settings.AggregateClrTypeHeader]?.ToString(); var aggregateStreamId = metaData[Settings.AggregateIdHeader]?.ToString() ?? Guid.NewGuid().ToString(); // k.Substring(k.IndexOf('-') + 1); System.Console.WriteLine(aggregateStreamId); var aggregateKey = new AggregateKey(Type.GetType(aggregateStreamType), Guid.Parse(aggregateStreamId)); var aggrEvent = new AggregateEvent <TDomainEvent>(aggregateKey, e); eventsForAggregate.Add(aggrEvent); } } while (!currentSlice.IsEndOfStream); return(eventsForAggregate); }
public async void ShouldBeParsedInAnyOrderUsingExtensions() { var web3 = _ethereumClientIntegrationFixture.GetWeb3(); var senderAddress = AccountFactory.Address; var receipt = await web3.Eth.DeployContract.SendRequestAndWaitForReceiptAsync(BYTE_CODE, senderAddress, new HexBigInteger(900000), null); var contract = web3.Eth.GetContract(ABI, receipt.ContractAddress); var function = contract.GetFunction("sendEvent"); receipt = await function.SendTransactionAndWaitForReceiptAsync(senderAddress, new HexBigInteger(900000), null, null); var events = EventExtensions.DecodeAllEvents <EventEventDTO>(receipt.Logs); Assert.Equal(1, events[0].Event.First); Assert.Equal(2, events[0].Event.Second); Assert.Equal(3, events[0].Event.Third); Assert.Equal(4, events[0].Event.Fourth); }
public static IEnumerable <TResult> SortEvents <TResult, T>( this IEnumerable <TResult> events, SortedBy sortByType, params Expression <Func <TResult, T> >[] expressions) { IEnumerable <TResult> retVal = null; switch (sortByType) { case SortedBy.Ascending: retVal = EventExtensions.SortEventsAsc(events, expressions); break; case SortedBy.Descending: retVal = EventExtensions.SortEventsDesc(events, expressions); break; default: throw new InvalidOperationException( string.Format("The SortedBy enumeration does not contain a case for the value of '{0}'.", Enum.GetName(typeof(SortedBy), sortByType))); } return(retVal); }
public bool Move(int x, int y, uint ticks, TravelType travelType, out bool eventTriggered, bool displayOuchIfBlocked = true, CharacterDirection?prevDirection = null, bool updateDirectionIfNotMoving = true) // x,y in tiles { eventTriggered = false; if (player.MovementAbility == PlayerMovementAbility.NoMovement) { return(false); } bool canMove = true; var map = Map.Map; int newX = Position.X + x; int newY = Position.Y + y; Map.Tile tile = null; if (!map.IsWorldMap) { // Don't leave the map. if (newX < 0 || newY < 0 || newX >= map.Width || newY >= map.Height) { canMove = false; } else { tile = Map[(uint)newX, (uint)newY]; } } else { while (newX < 0) { newX += map.Width; } while (newY < 0) { newY += map.Height; } tile = Map[(uint)newX, (uint)newY]; } if (canMove) { var tileset = mapManager.GetTilesetForMap(map); canMove = tile.AllowMovement(tileset, travelType); if (!canMove && travelType == TravelType.Swim && tile.AllowMovement(tileset, TravelType.Walk)) { canMove = true; // go on land } if (!travelType.IgnoreEvents()) { // check if there is a place, teleport, riddlemouth, chest // or door event at the new position var mapEventId = Map[(uint)newX, (uint)newY]?.MapEventId; if (mapEventId > 0 && game.CurrentSavegame.IsEventActive(map.Index, mapEventId.Value - 1)) { var trigger = EventTrigger.Move; bool lastEventStatus = false; bool HasSpecialEvent(Event ev, out EventType?eventType) { eventType = null; if (ev.Type == EventType.EnterPlace || (ev is TeleportEvent teleportEvent && teleportEvent.Transition != TeleportEvent.TransitionType.WindGate) || ev.Type == EventType.Riddlemouth || (ev.Type == EventType.Chest && Map.Map.IsWorldMap) || (ev is DoorEvent doorEvent && game.CurrentSavegame.IsDoorLocked(doorEvent.DoorIndex))) { eventType = ev.Type; return(true); } if (ev.Next == null) { return(false); } if (ev is ConditionEvent conditionEvent) { ev = conditionEvent.ExecuteEvent(map, game, ref trigger, (uint)Position.X, (uint)Position.Y, game.CurrentTicks, ref lastEventStatus, out bool aborted, out _); if (aborted || ev == null) { return(false); } } if (ev.Next == null) { return(false); } return(HasSpecialEvent(ev.Next, out eventType)); } var mapAtNewPosition = Map.GetMapFromTile((uint)newX, (uint)newY); if (HasSpecialEvent(mapAtNewPosition.EventList[(int)mapEventId.Value - 1], out var type)) { if ((type != EventType.Teleport || !travelType.BlockedByTeleport()) && EventExtensions.TriggerEventChain(mapAtNewPosition, game, EventTrigger.Move, (uint)x, (uint)y, ticks, mapAtNewPosition.EventList[(int)mapEventId.Value - 1])) { eventTriggered = true; return(false); } else { canMove = false; } } } } if (canMove && tile.Type == Data.Map.TileType.Water && travelType.BlockedByWater()) { canMove = false; } } if (canMove) { var oldMap = map; int scrollX = 0; int scrollY = 0; prevDirection ??= Direction; var newDirection = CharacterDirection.Down; var lastPlayerPosition = new Position(player.Position); if (x > 0 && (map.IsWorldMap || (newX >= 6 && Map.ScrollX < Map.Map.Width - RenderMap2D.NUM_VISIBLE_TILES_X))) { scrollX = 1; } else if (x < 0 && (map.IsWorldMap || (newX <= map.Width - 7 && Map.ScrollX > 0))) { scrollX = -1; } if (y > 0 && (map.IsWorldMap || (newY >= 5 && Map.ScrollY < Map.Map.Height - RenderMap2D.NUM_VISIBLE_TILES_Y))) { scrollY = 1; } else if (y < 0 && (map.IsWorldMap || (newY <= map.Height - 6 && Map.ScrollY > 0))) { scrollY = -1; } if (y > 0) { newDirection = CharacterDirection.Down; } else if (y < 0) { newDirection = CharacterDirection.Up; } else if (x > 0) { newDirection = CharacterDirection.Right; } else if (x < 0) { newDirection = CharacterDirection.Left; } player.Direction = newDirection; Map.Scroll(scrollX, scrollY); if (oldMap == Map.Map) { bool frameReset = NumFrames == 1 || newDirection != prevDirection; var prevState = CurrentState; MoveTo(oldMap, (uint)newX, (uint)newY, ticks, frameReset, null); if (travelType == TravelType.Walk) { Map.TriggerEvents(this, EventTrigger.Move, (uint)newX, (uint)newY, mapManager, ticks, game.CurrentSavegame); } if (oldMap == Map.Map) // might have changed by map change events { if (!frameReset && CurrentState == prevState) { SetCurrentFrame((CurrentFrame + 1) % NumFrames); } player.Position.X = Position.X; player.Position.Y = Position.Y; tile = Map[(uint)player.Position.X, (uint)player.Position.Y]; Visible = travelType != TravelType.Walk || tile.Type != Data.Map.TileType.Invisible; game.PlayerMoved(false, lastPlayerPosition); } } else { // adjust player position on map transition var position = Map.GetCenterPosition(); MoveTo(Map.Map, (uint)position.X, (uint)position.Y, ticks, false, player.Direction); if (travelType == TravelType.Walk) { Map.TriggerEvents(this, EventTrigger.Move, (uint)position.X, (uint)position.Y, mapManager, ticks, game.CurrentSavegame); } if (Map.Map.Type == MapType.Map2D) { player.Position.X = Position.X; player.Position.Y = Position.Y; // Note: For 3D maps the game/3D map will handle player position updating. tile = Map[(uint)player.Position.X, (uint)player.Position.Y]; Visible = travelType != TravelType.Walk || tile.Type != Data.Map.TileType.Invisible; game.PlayerMoved(true, null, true, oldMap); } } } else { if (displayOuchIfBlocked) { game.DisplayOuch(); } if (updateDirectionIfNotMoving) { // If not able to move, the direction should be adjusted var newDirection = Direction; if (y > 0) { newDirection = CharacterDirection.Down; } else if (y < 0) { newDirection = CharacterDirection.Up; } else if (x > 0) { newDirection = CharacterDirection.Right; } else if (x < 0) { newDirection = CharacterDirection.Left; } if (newDirection != Direction) { MoveTo(Map.Map, (uint)Position.X, (uint)Position.Y, ticks, true, newDirection); player.Direction = newDirection; game.CurrentSavegame.CharacterDirection = newDirection; UpdateAppearance(game.CurrentTicks); } } } return(canMove); }
private void AccelerometerOnReadingChanged(AccelerometerSensor sender, AccelerometerReadingChangedEventArgs args) { LatestReading = args.Reading.AsVector3(); EventExtensions.Invoke <Vector3>(readingAvailable, sender, LatestReading); }
protected void StartEventProcessors() { EventExtensions.StartEventProcessors(ServiceProvider); }
public static EventABI GetEventABI() { return(EventExtensions.GetEventABI <TransferEventDTO>()); }
/// <summary> /// Gyroscope reading has changed. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The gyroscope event arguments.</param> private void GyroscopeReadingChanged(Gyrometer sender, GyrometerReadingChangedEventArgs args) { LatestReading = args.Reading.AsVector3(); EventExtensions.Invoke <Vector3>(readingAvailable, this, this.LatestReading); }