Created
November 8, 2018 18:02
-
-
Save Lutando/a6bb6470dd599f2bf5e07901c49bf7e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomAdapter : DefaultEventAdapter | |
{ | |
protected override byte[] ToBytes(object @event, JObject metadata, out string type, out bool isJson) | |
{ | |
var bytes = base.ToBytes(@event, metadata, out type, out isJson); | |
//Add some additional metadata: | |
metadata["additionalProp"] = true; | |
//set the type yourself | |
switch (@event) | |
{ | |
case CommittedEvent<UserAccountAggregate, UserAccountId, UserAccountCreatedEvent> s: | |
type = "UserAccountAggregate.UserAccountCreatedEvent.0"; | |
break; | |
case CommittedEvent<UserAccountAggregate, UserAccountId, UserAccountNameChangedEvent> s: | |
type = "UserAccountAggregate.UserAccountNameChangedEvent.0"; | |
break; | |
} | |
return bytes; | |
} | |
protected override object ToEvent(byte[] bytes, JObject metadata) | |
{ | |
//Use the metadata to determine if you need to do something additional to the data | |
//Do something additional with bytes before handing it off to be deserialized. | |
return base.ToEvent(bytes, metadata); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment