public void DispatchEvent <T>(ref T e) where T : EventBase { //Get the event's class Type eventClass = e.GetType(); //Loop through the attributes foreach (Attribute classAttrib in eventClass.GetCustomAttributes()) { //if the attribute is an event header if (classAttrib is EventHeader) { EventHeader header = classAttrib as EventHeader; //Get the callbacks List <MethodInfo> callbacks = GetItem(header.eventName); //Check that the callbacks are null/bad if (callbacks == null) { continue; } if (callbacks.Count == 0) { continue; } //Call the callbacks foreach (MethodInfo callback in callbacks) { callback.Invoke(null, new object[] { e }); } return; } } }
/// <summary> /// Parses <see cref="RotateEvent"/> from the buffer. /// </summary> public IBinlogEvent ParseEvent(EventHeader header, ref PacketReader reader) { var binlogPosition = reader.ReadInt64LittleEndian(); var binlogFilename = reader.ReadStringToEndOfFile(); return(new RotateEvent(header, binlogFilename, binlogPosition)); }
public async Task Create(CreateEventHeaderDto input) { var @eventHeader = input.MapTo <EventHeader>(); @eventHeader = EventHeader.Create(AbpSession.GetTenantId(), input.Name, input.Description, input.Type, input.Date.Value, input.Frequency, input.ExpectedDate.Value, input.Department, input.Venue); await _eventHeaderRepository.InsertAsync(@eventHeader); }
/// <summary> /// Creates a new <see cref="XaPrepareEvent"/>. /// </summary> public XaPrepareEvent(EventHeader header, bool onePhase, int formatId, string gtrid, string bqual) : base(header) { OnePhase = onePhase; FormatId = formatId; Gtrid = gtrid; Bqual = bqual; }
/// <summary> /// Parses <see cref="IntVarEvent"/> from the buffer. /// </summary> public IBinlogEvent ParseEvent(EventHeader header, ref PacketReader reader) { var type = reader.ReadByte(); var value = reader.ReadInt64LittleEndian(); return(new IntVarEvent(header, type, value)); }
public static EventHeader Insert(this IDbConnection conn, EventHeader input) { return(conn.GetReader("insert into [EventHeaders] " + "([EventId],[Name],[Value]) values (@p0,@p1,@p2);" + " select [EventId],[Name],[Value] from [EventHeaders] where [EventId]=@p0 and [Name]=@p1;", input.EventId, input.Name, input.Value).Select(x => x.ToEventHeader()).First()); }
public void Main() { var eventHeader = new EventHeader(); var student = new Student() { Name = "Grace Hopper", StartYear = 1952 }; var course = new Course() { Name = "Assembly Programming", Length = 40 }; var studentHistoryService = new StudentHistoryService(); var studentHistoryResult = studentHistoryService.AddHistoryEvent(eventHeader, student); Console.WriteLine(studentHistoryResult); var courseHistoryService = new CourseHistoryService(); var courseHistoryResult = courseHistoryService.AddHistoryEvent(eventHeader, course); Console.WriteLine(courseHistoryResult); Console.ReadLine(); }
public static Event Deserialize(List <byte[]> envelope, byte[] data) { MessagePackObject payloadData = Unpacking.UnpackObject(data).Value; IList <MessagePackObject> parts; MessagePackObjectDictionary header; if (!payloadData.IsArray || (parts = payloadData.AsList()).Count != 3) { throw new Exception("Expected array of size 3"); } if (!parts[0].IsMap || !(header = parts[0].AsDictionary()).ContainsKey("message_id")) { throw new Exception("Bad header"); } if (parts[1].AsString() == null) { throw new Exception("Bad name"); } var headerObj = new EventHeader { Version = header["v"].AsInt32(), MessageId = ProcessUuid(header, "message_id"), ResponseTo = ProcessUuid(header, "response_to") }; var msg = new Event { Envelope = envelope, Header = headerObj, Name = parts[1].AsString(), Args = parts[2].AsList() }; return(msg); }
public bool SaveEvents(IEnumerable <object> events) { foreach (var evt in events) { var evtblob = new EventBlob { TypeFullName = evt.GetType().FullName, TypeName = evt.GetType().Name, }; serializer.Serialize(evt, ref evtblob); var headers = new List <EventHeader>(); foreach (var p in evt.GetType().GetProperties().Where(x => x.Name.EndsWith("Id"))) { var val = p.GetValue(evt, null); if (val == null) { continue; } var hdr = new EventHeader { Name = p.Name, Value = val.ToString() }; headers.Add(hdr); } adapter.SaveEvent(evtblob, headers); } return(true); }
/// <summary> /// Parses <see cref="TableMapEvent"/> from the buffer. /// </summary> public IBinlogEvent ParseEvent(EventHeader header, ref PacketReader reader) { var tableId = reader.ReadLongLittleEndian(6); // Reserved bytes and database name length reader.Advance(3); var databaseName = reader.ReadNullTerminatedString(); // Table name length reader.Advance(1); var tableName = reader.ReadNullTerminatedString(); var columnsNumber = (int)reader.ReadLengthEncodedNumber(); var columnTypes = reader.ReadByteArraySlow(columnsNumber); var metadataLength = (int)reader.ReadLengthEncodedNumber(); var metadata = ParseMetadata(ref reader, columnTypes); var nullBitmap = reader.ReadBitmapLittleEndian(columnsNumber); TableMetadata tableMetadata = null; if (!reader.IsEmpty()) { // Table metadata is supported in MySQL 5.6+ and MariaDB 10.5+. tableMetadata = new TableMetadata(ref reader, columnTypes); } return(new TableMapEvent(header, tableId, databaseName, tableName, columnTypes, metadata, nullBitmap, tableMetadata)); }
public void HasKeyfound() { EventHeader sut = GetSut(); sut.Set("foo", "dfsdf"); Assert.True(sut.HasKey("foo")); }
public void GetEventType() { EventHeader sut = GetSut(); Type type = sut.ResolveEventType(); Assert.Equal(type, typeof(SampleEvent)); }
public void ItResolvesAggregateId() { EventHeader sut = GetSut(); string id = sut.AggregateId; Assert.Equal(id, expectedId); }
/// <summary> /// Parses <see cref="RowsQueryEvent"/> from the buffer. /// </summary> public IBinlogEvent ParseEvent(EventHeader header, ref PacketReader reader) { reader.Advance(1); var query = reader.ReadStringToEndOfFile(); return(new RowsQueryEvent(header, query)); }
public void CreateBlankEvent() { EventToAdd = new EventHeader(); EventToAdd.VersionNo = 1; EventToAdd.PropertyChanged += OnTargetUpdated; EventToAdd.TenantId = TenantId; }
public WhenSettingDefaults() { EventHeader sut = GetSut(); sut.SetDetaults("123"); this.sut = sut; }
/// <summary> /// HeaderNamespace and Name can be left null. Namespaces.Alexa and HeaderNames.Response will be used /// </summary> /// <param name="h"></param> /// <param name="source"></param> /// <param name="headerNamespace"></param> /// <param name="headerName"></param> public static void CheckResponseCreatedBaseHeader(EventHeader h, DirectiveHeader source, string headerNamespace = Namespaces.ALEXA, string headerName = HeaderNames.RESPONSE) { Assert.NotNull(h); Assert.Equal(headerNamespace, h.Namespace); Assert.Equal(headerName, h.Name); Assert.Equal("3", h.PayloadVersion); Assert.Equal(source.CorrelationToken, h.CorrelationToken); }
protected EventHeader GetSut() { var sut = new EventHeader(); sut.Set(EventHeaderKeys.EventType, typeof(SampleEvent).AssemblyQualifiedName); sut.Set(EventHeaderKeys.AggregateId, expectedId); return(sut); }
public static ReadonlyEvent Parse(EventHeader head, string tail, IServiceProvider service) { var eventData = tail.Split('/'); //This looks kinda wonky, but is O(n) and handles better than a switch. return(Categories[head.Category] [head.Action] (eventData, service)); }
public void TestConstructor() { var expectedEventId = "eventId"; var subject = new EventHeader (expectedEventId); subject.EventId.Should ().NotBeNullOrEmpty (); subject.EventId.Should ().Be (expectedEventId); }
/// <summary> /// Parses <see cref="DeleteRowsEvent"/> from the buffer. /// </summary> public IBinlogEvent ParseEvent(EventHeader header, ref PacketReader reader) { var shared = ParseHeader(ref reader); var columnsPresent = reader.ReadBitmapLittleEndian(shared.columnsNumber); var rows = ParseDeleteRows(ref reader, shared.tableId, columnsPresent); return(new DeleteRowsEvent(header, shared.tableId, shared.flags, shared.columnsNumber, columnsPresent, rows)); }
/// <summary> /// Parses <see cref="GtidEvent"/> from the buffer. /// </summary> public IBinlogEvent ParseEvent(EventHeader header, ref PacketReader reader) { var flags = reader.ReadByte(); var sourceId = new Uuid(reader.ReadByteArraySlow(16)); var transactionId = reader.ReadInt64LittleEndian(); var gtid = new Gtid(sourceId, transactionId); return(new GtidEvent(header, gtid, flags)); }
static EventHeader ToEventHeader(this IDataReader dr) { var bl = new EventHeader(); bl.EventId = dr.GetInt32(0); bl.Name = dr.GetString(1); bl.Value = dr.GetString(2); return(bl); }
/// <summary> /// Parses <see cref="GtidEvent"/> from the buffer. /// </summary> public IBinlogEvent ParseEvent(EventHeader header, ref PacketReader reader) { long sequence = reader.ReadInt64LittleEndian(); long domainId = reader.ReadUInt32LittleEndian(); var gtid = new Gtid(domainId, header.ServerId, sequence); byte flags = reader.ReadByte(); return(new GtidEvent(header, gtid, flags)); }
public void GettingStringAsDatetimeThrows() { EventHeader sut = GetSut(); var expected = "sdmnfö2342ütäerfd"; sut.Set("foo", expected); Assert.Throws <InvalidCastException>(() => sut.GetDateTime("foo")); }
/// <summary> /// Parses <see cref="GtidEvent"/> from the buffer. /// </summary> public IBinlogEvent ParseEvent(EventHeader header, ref PacketReader reader) { var sequence = reader.ReadInt64LittleEndian(); long domainId = (uint)reader.ReadInt32LittleEndian(); var gtid = $"{domainId}-{header.ServerId}-{sequence}"; var flags = reader.ReadByte(); return(new GtidEvent(header, gtid, flags)); }
public string AddHistoryEvent <THistoryData>(EventHeader eventHeader, THistoryData historyData) { var historyEvent = CreateEvent(); historyEvent.EventHeader = eventHeader; var result = "HistoryService: " + historyEvent.InsertRecord <THistoryData>(historyData); return(result); }
public IEvent DeserializeEvent(Dictionary <string, string> headerData, string eventData) { var header = new EventHeader(headerData); Type type = eventTypeResolver.ResolveType(header); var result = JsonConvert.DeserializeObject(eventData, type, SerializerSettings) as IEvent; result?.Headers.ApplyEventHeader(header); return(result); }
/// <summary> /// Parses <see cref="XaPrepareEvent"/> from the buffer. /// </summary> public IBinlogEvent ParseEvent(EventHeader header, ref PacketReader reader) { bool onePhase = reader.ReadByte() != 0x00; int formatId = (int)reader.ReadUInt32LittleEndian(); int gtridLength = (int)reader.ReadUInt32LittleEndian(); int bqualLength = (int)reader.ReadUInt32LittleEndian(); string gtrid = reader.ReadString(gtridLength); string bqual = reader.ReadString(bqualLength); return(new XaPrepareEvent(header, onePhase, formatId, gtrid, bqual)); }
public virtual IEvent DeserializeEvent(Dictionary <string, string> headerData, string eventData) { var header = new EventHeader(headerData); Type type = eventTypeResolver.ResolveType(header); IEvent result = DeserializeEventInternal(eventData, type); result?.Headers.ApplyEventHeader(header); return(result); }
public virtual IEvent DeserializeEvent(string headerData, string eventData) { EventHeader header = DeserializeHeader(headerData); Type type = eventTypeResolver.ResolveType(header); IEvent result = DeserializeEventInternal(eventData, type); result?.Headers.ApplyEventHeader(header); return(result); }
public EventEnvelope(EventHeader header, object @event) { Header = header; Event = @event; }