Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public static TObject Map <TObject>(
     this IGangSerializationService service, object value)
 {
     return((TObject)service.Map(value, typeof(TObject)));
 }