Example #1
0
        public MongoDbSnapshotStore()
        {
            _settings = MongoDbPersistence.Get(Context.System).SnapshotStoreSettings;

            var serialization = Context.System.Serialization;

            switch (_settings.StoredAs)
            {
            case StoredAsType.Binary:
                _serialize = o =>
                {
                    var serializer = serialization.FindSerializerFor(o);
                    return(new SerializationResult(serializer.ToBinary(o), serializer));
                };
                _deserialize = (type, serialized, manifest, serializerId) =>
                {
                    if (serializerId.HasValue)
                    {
                        return(serialization.Deserialize((byte[])serialized, serializerId.Value, manifest));
                    }
                    var deserializer = serialization.FindSerializerForType(type);
                    return(deserializer.FromBinary((byte[])serialized, type));
                };
                break;

            default:
                _serialize   = o => new SerializationResult(o, null);
                _deserialize = (type, serialized, manifest, serializerId) => serialized;
                break;
            }
        }
        public MongoDbSnapshotStore()
        {
            _settings = MongoDbPersistence.Get(Context.System).SnapshotStoreSettings;

            var serialization = Context.System.Serialization;

            switch (_settings.StoredAs)
            {
            case StoredAsType.Binary:
                _serialize = o =>
                {
                    var serializer = serialization.FindSerializerFor(o);
                    return(new SerializationResult(serializer.ToBinary(o), serializer));
                };
                _deserialize = (type, serialized, manifest, serializerId) =>
                {
                    if (serializerId.HasValue)
                    {
                        /*
                         * Backwards compat: check to see if manifest is populated before using it.
                         * Otherwise, fall back to using the stored type data instead.
                         * Per: https://github.com/AkkaNetContrib/Akka.Persistence.MongoDB/issues/57
                         */
                        if (string.IsNullOrEmpty(manifest))
                        {
                            return(serialization.Deserialize((byte[])serialized, serializerId.Value, type));
                        }
                        return(serialization.Deserialize((byte[])serialized, serializerId.Value, manifest));
                    }

                    var deserializer = serialization.FindSerializerForType(type);
                    return(deserializer.FromBinary((byte[])serialized, type));
                };
                break;

            default:
                _serialize   = o => new SerializationResult(o, null);
                _deserialize = (type, serialized, manifest, serializerId) => serialized;
                break;
            }
        }
        public MongoDbSnapshotStore()
        {
            _settings = MongoDbPersistence.Get(Context.System).SnapshotStoreSettings;

            _serialization = Context.System.Serialization;
        }
 public MongoDbSnapshotStore()
 {
     _settings = MongoDbPersistence.Get(Context.System).SnapshotStoreSettings;
 }
Example #5
0
 public MongoDbSnapshotStore()
 {
     _settings = MongoDbPersistence.Get(Context.System).SnapshotStoreSettings;
 }