async Task <GangState <TStateData> > IGangStateStore .RestoreAsync <TStateData>( string gangId, TStateData initial ) where TStateData : class { var data = await _cache.TryGetAsync(gangId); var state = _serializer.Map <GangState <TStateData> >(data); return(state ?? await RehydrateAsync(gangId, initial)); }
IGangCommand IGangCommandExecutor <TStateData> .Deserialize( byte[] bytes, GangAudit audit ) { var wrapper = _serialization.Deserialize <GangCommandWrapper>(bytes); if (!_handlers.ContainsKey(wrapper.Type)) { throw new GangCommandHandlerNotFoundExcetion(); } var type = _handlers[wrapper.Type].DataType; return(GangCommand.From( _serialization.Map(wrapper.Data, type), audit)); }
public static TObject Map <TObject>( this IGangSerializationService service, object value) { return((TObject)service.Map(value, typeof(TObject))); }