public MongoPersistenceWireup(Wireup inner, string connectionName, IDocumentSerializer serializer) : base(inner) { this.Container.Register(c => new MongoPersistenceFactory( connectionName, serializer).Build()); }
public static Snapshot ToSnapshot(this BsonDocument doc, IDocumentSerializer serializer) { if (doc == null) return null; var id = doc["_id"].AsBsonDocument; var streamId = id["StreamId"].AsGuid; var streamRevision = id["StreamRevision"].AsInt32; var bsonPayload = doc["Payload"]; object payload; switch (bsonPayload.BsonType) { case BsonType.Binary: payload = serializer.Deserialize<object>(bsonPayload.AsByteArray); break; case BsonType.Document: payload = BsonSerializer.Deserialize<object>(bsonPayload.AsBsonDocument); break; default: payload = bsonPayload.RawValue; break; } return new Snapshot( streamId, streamRevision, payload); }
public static BsonDocument ToMongoSnapshot(this Snapshot snapshot, IDocumentSerializer serializer) { return new BsonDocument { { "_id", new BsonDocument { { "StreamId", snapshot.StreamId }, { "StreamRevision", snapshot.StreamRevision } } }, { "Payload", BsonDocumentWrapper.Create(serializer.Serialize(snapshot.Payload)) } }; }
public static Snapshot ToSnapshot(this RavenSnapshot snapshot, IDocumentSerializer serializer) { if (snapshot == null) return null; return new Snapshot(snapshot.BucketId, snapshot.StreamId, snapshot.StreamRevision, serializer.Deserialize<object>(snapshot.Payload)); }
public static RavenSnapshot ToRavenSnapshot(this Snapshot snapshot, IDocumentSerializer serializer) { return new RavenSnapshot { StreamId = snapshot.StreamId, StreamRevision = snapshot.StreamRevision, Payload = serializer.Serialize(snapshot.Payload) }; }
public static Commit ToCommit(this RavenCommit commit, IDocumentSerializer serializer) { return new Commit(commit.StreamId, commit.StreamRevision, commit.CommitId, commit.CommitSequence, commit.CommitStamp, commit.Headers, serializer.Deserialize<List<EventMessage>>(commit.Payload)); }
public static RavenSnapshot ToRavenSnapshot(this Snapshot snapshot, string partition, IDocumentSerializer serializer) { return new RavenSnapshot { Id = ToRavenSnapshotId(snapshot, partition), Partition = partition, StreamId = snapshot.StreamId, StreamRevision = snapshot.StreamRevision, Payload = serializer.Serialize(snapshot.Payload) }; }
public static PersistenceWireup UsingMongoPersistence(this Wireup wireup, string connectionName, IDocumentSerializer serializer, MongoPersistenceOptions options = null) { return new MongoPersistenceWireup(wireup, () => { var connectionStringSettings = ConfigurationManager.ConnectionStrings[connectionName]; if( connectionStringSettings == null) throw new ConfigurationErrorsException(Messages.ConnectionNotFound.FormatWith(connectionName)); return connectionStringSettings.ConnectionString; }, serializer, options); }
public RavenPersistenceFactory( string connectionName, IDocumentSerializer serializer, TransactionScopeOption scopeOption, bool consistentQueries) { this.ConnectionStringName = connectionName; this.serializer = serializer; this.scopeOption = scopeOption; this.consistentQueries = consistentQueries; }
public MongoPersistenceWireup(Wireup inner, string connectionName, IDocumentSerializer serializer) : base(inner) { Logger.Debug("Configuring Mongo persistence engine."); var options = Container.Resolve<TransactionScopeOption>(); if (options != TransactionScopeOption.Suppress) { Logger.Warn("MongoDB does not participate in transactions using TransactionScope."); } Container.Register(c => new MongoPersistenceFactory(connectionName, serializer).Build()); }
public RavenPersistenceWireup( Wireup inner, string connectionName, IDocumentSerializer serializer, bool consistentQueries) : base(inner) { this.Container.Register(c => new RavenPersistenceFactory( connectionName, serializer, this.Container.Resolve<TransactionScopeOption>(), consistentQueries).Build()); }
public static BsonDocument ToMongoCommit(this Commit commit, IDocumentSerializer serializer) { var streamRevision = commit.StreamRevision - (commit.Events.Count - 1); var events = commit.Events.Select(e => new BsonDocument { { "StreamRevision", streamRevision++ }, { "Payload", new BsonDocumentWrapper(typeof(EventMessage), serializer.Serialize(e)) } }); return new BsonDocument { { "_id", new BsonDocument { { "StreamId", commit.StreamId }, { "CommitSequence", commit.CommitSequence } } }, { "CommitId", commit.CommitId }, { "CommitStamp", commit.CommitStamp }, { "Headers", BsonDocumentWrapper.Create(commit.Headers) }, { "Events", BsonArray.Create(events) }, { "Dispatched", false } }; }
public static ICommit ToCommit(this RavenCommit commit, IDocumentSerializer serializer) { return new Commit( commit.BucketId, commit.StreamId, commit.StreamRevision, commit.CommitId, commit.CommitSequence, commit.CommitStamp, commit.CheckpointNumber.ToString(CultureInfo.InvariantCulture), commit.Headers, serializer.Deserialize<IList<EventMessage>>(commit.Payload) ); }
public static RavenCommit ToRavenCommit(this Commit commit, IDocumentSerializer serializer) { return new RavenCommit { Id = ToRavenCommitId(commit), StreamId = commit.StreamId, CommitSequence = commit.CommitSequence, StartingStreamRevision = commit.StreamRevision - (commit.Events.Count - 1), StreamRevision = commit.StreamRevision, CommitId = commit.CommitId, CommitStamp = commit.CommitStamp, Headers = commit.Headers, Payload = serializer.Serialize(commit.Events) }; }
public static RavenCommit ToRavenCommit(this CommitAttempt commit, IDocumentSerializer serializer) { return new RavenCommit { Id = ToRavenCommitId(commit), BucketId = commit.BucketId, StreamId = commit.StreamId, CommitSequence = commit.CommitSequence, StartingStreamRevision = commit.StreamRevision - (commit.Events.Count - 1), StreamRevision = commit.StreamRevision, CommitId = commit.CommitId, CommitStamp = commit.CommitStamp, Headers = commit.Headers.ToDictionary(kvp => kvp.Key, kvp => kvp.Value), Payload = serializer.Serialize(commit.Events) }; }
public static Commit ToCommit(this BsonDocument doc, IDocumentSerializer serializer) { if (doc == null) return null; var id = doc["_id"].AsBsonDocument; var streamId = id["StreamId"].AsGuid; var commitSequence = id["CommitSequence"].AsInt32; var events = doc["Events"].AsBsonArray.Select(e => e.AsBsonDocument["Payload"].IsBsonDocument ? BsonSerializer.Deserialize<EventMessage>(e.AsBsonDocument["Payload"].AsBsonDocument) : serializer.Deserialize<EventMessage>(e.AsBsonDocument["Payload"].AsByteArray)).ToList(); var streamRevision = doc["Events"].AsBsonArray.Last().AsBsonDocument["StreamRevision"].AsInt32; return new Commit( streamId, streamRevision, doc["CommitId"].AsGuid, commitSequence, doc["CommitStamp"].AsDateTime, BsonSerializer.Deserialize<Dictionary<string, object>>(doc["Headers"].AsBsonDocument), events); }
public MongoPersistenceFactoryFromConnectionString(string connectionString, IDocumentSerializer serializer) : base(connectionString, serializer) { _connectionString = connectionString; }
public FormatConverter(InputParser inputParser, IDocumentSerializer documentSerializer) { this.inputParser = inputParser; this.documentSerializer = documentSerializer; }
public static Wireup UsingMongoPersistence( this Wireup wireup, string connectionName, IDocumentSerializer serializer) { wireup.With(new MongoPersistenceFactory(connectionName, serializer).Build()); return wireup; }
public MongoPersistenceFactory(string connectionName, IDocumentSerializer serializer) { this.connectionName = connectionName; this.serializer = serializer; }
public ResourceVariableProvider(ISender sender, IDocumentSerializer documentSerializer, ILogger logger) : base(sender, documentSerializer, "resources", logger) { }
/// <summary> /// Creates a new instance of the HttpTransportListener class. /// </summary> /// <param name="port">The port for listening.</param> /// <param name="hostName">Name of the host for binding.</param> /// <param name="useHttps">if set to <c>true</c> the listener endpoint will use HTTPS.</param> /// <param name="requestTimeout">The request timeout.</param> /// <param name="writeExceptionsToOutput">if set to <c>true</c> the exceptions details will be written in the response body.</param> /// <param name="httpServer">The HTTP server instance.</param> /// <param name="httpTransportProvider">The HTTP transport provider instance.</param> /// <param name="serializer">The serializer instance.</param> /// <param name="messageStorage">The message storage instance.</param> /// <param name="notificationStorage">The notification storage instance.</param> /// <param name="processors">The processors.</param> /// <param name="traceWriter">The trace writer.</param> public HttpTransportListener(int port, string hostName = "*", bool useHttps = false, TimeSpan requestTimeout = default(TimeSpan), TimeSpan transportExpirationInactivityInterval = default(TimeSpan), bool writeExceptionsToOutput = true, int maxDegreeOfParallelism = 1, IHttpServer httpServer = null, IHttpTransportProvider httpTransportProvider = null, IDocumentSerializer serializer = null, IEnvelopeStorage <Message> messageStorage = null, IEnvelopeStorage <Notification> notificationStorage = null, IHttpProcessor[] processors = null, ITraceWriter traceWriter = null) { _useHttps = useHttps; var scheme = _useHttps ? Uri.UriSchemeHttps : Uri.UriSchemeHttp; _writeExceptionsToOutput = writeExceptionsToOutput; _maxDegreeOfParallelism = maxDegreeOfParallelism; _requestTimeout = requestTimeout != default(TimeSpan) ? requestTimeout : TimeSpan.FromSeconds(Constants.DEFAULT_REQUEST_TIMEOUT); var basePath = string.Format("{0}://{1}:{2}", scheme, hostName, port); var prefixes = new string[] { Constants.ROOT + Constants.MESSAGES_PATH + Constants.ROOT, Constants.ROOT + Constants.COMMANDS_PATH + Constants.ROOT, Constants.ROOT + Constants.NOTIFICATIONS_PATH + Constants.ROOT }; var fullPrefixes = prefixes.Select(p => basePath + p).ToArray(); var safeHostName = hostName; if (hostName.Equals("*") || hostName.Equals("+")) { safeHostName = "localhost"; } var baseUri = new Uri(string.Format("{0}://{1}:{2}", scheme, safeHostName, port)); ListenerUris = prefixes .Select(p => new Uri(baseUri, p)) .ToArray(); _httpServer = httpServer ?? new HttpServer(fullPrefixes, AuthenticationSchemes.Basic); _serializer = serializer ?? new DocumentSerializer(); _messageStorage = messageStorage ?? new DictionaryEnvelopeStorage <Message>(); _notificationStorage = notificationStorage ?? new DictionaryEnvelopeStorage <Notification>(); _traceWriter = traceWriter; transportExpirationInactivityInterval = transportExpirationInactivityInterval != default(TimeSpan) ? transportExpirationInactivityInterval : TimeSpan.FromSeconds(Constants.DEFAULT_TRANSPORT_EXPIRATION_INACTIVITY_INTERVAL); _httpTransportProvider = httpTransportProvider ?? new HttpTransportProvider(_useHttps, _messageStorage, _notificationStorage, transportExpirationInactivityInterval); _httpTransportProvider.TransportCreated += async(sender, e) => await _transportBufferBlock.SendAsync(e.Transport, _listenerCancellationTokenSource.Token).ConfigureAwait(false); // Context processors _uriTemplateTable = new UriTemplateTable(baseUri); if (processors == null) { processors = CreateProcessors(); } foreach (var processor in processors) { _uriTemplateTable.KeyValuePairs.Add(new KeyValuePair <UriTemplate, object>(processor.Template, processor)); } _uriTemplateTable.MakeReadOnly(true); }
public static PersistenceWireup UsingMongoPersistence(this Wireup wireup, Func<string> connectionStringProvider, IDocumentSerializer serializer, MongoPersistenceOptions options = null) { return new MongoPersistenceWireup(wireup, connectionStringProvider, serializer, options); }
public static StorageDocument ToStorageDocument(this Document document, IDocumentSerializer documentSerializer) => new StorageDocument { Document = documentSerializer.Serialize(document), Type = document.GetMediaType() };
public static BsonDocument ToMongoCommit(this CommitAttempt commit, LongCheckpoint checkpoint, IDocumentSerializer serializer) { int streamRevision = commit.StreamRevision - (commit.Events.Count - 1); int streamRevisionStart = streamRevision; IEnumerable <BsonDocument> events = commit .Events .Select(e => new BsonDocument { { MongoCommitFields.StreamRevision, streamRevision++ }, { MongoCommitFields.Payload, new BsonDocumentWrapper(typeof(EventMessage), serializer.Serialize(e)) } }); return(new BsonDocument { { MongoCommitFields.CheckpointNumber, checkpoint.LongValue }, { MongoCommitFields.CommitId, commit.CommitId }, { MongoCommitFields.CommitStamp, commit.CommitStamp }, { MongoCommitFields.Headers, BsonDocumentWrapper.Create(commit.Headers) }, { MongoCommitFields.Events, new BsonArray(events) }, { MongoCommitFields.Dispatched, false }, { MongoCommitFields.StreamRevisionFrom, streamRevisionStart }, { MongoCommitFields.StreamRevisionTo, streamRevision - 1 }, { MongoCommitFields.BucketId, commit.BucketId }, { MongoCommitFields.StreamId, commit.StreamId }, { MongoCommitFields.CommitSequence, commit.CommitSequence } }); }
public static BsonDocument ToMongoCommit(this CommitAttempt commit, Int64 checkpoint, IDocumentSerializer serializer) { int streamRevision = commit.StreamRevision - (commit.Events.Count - 1); int streamRevisionStart = streamRevision; IEnumerable <BsonDocument> events = commit .Events .Select(e => new BsonDocument { { MongoCommitFields.StreamRevision, streamRevision++ }, { MongoCommitFields.Payload, BsonDocumentWrapper.Create(typeof(EventMessage), serializer.Serialize(e)) } }); var mc = new MongoCommit { CheckpointNumber = checkpoint, CommitId = commit.CommitId, CommitStamp = commit.CommitStamp, Headers = commit.Headers, Events = new BsonArray(events), StreamRevisionFrom = streamRevisionStart, StreamRevisionTo = streamRevision - 1, BucketId = commit.BucketId, StreamId = commit.StreamId, CommitSequence = commit.CommitSequence }; return(mc.ToBsonDocument()); }
public static BsonDocument ToMongoCommit_original(this CommitAttempt commit, Int64 checkpoint, IDocumentSerializer serializer) { int streamRevision = commit.StreamRevision - (commit.Events.Count - 1); int streamRevisionStart = streamRevision; IEnumerable <BsonDocument> events = commit .Events .Select(e => new BsonDocument { { MongoCommitFields.StreamRevision, streamRevision++ }, { MongoCommitFields.Payload, BsonDocumentWrapper.Create(typeof(EventMessage), serializer.Serialize(e)) } }); //var dictionarySerialize = new DictionaryInterfaceImplementerSerializer<Dictionary<string, object>>(DictionaryRepresentation.ArrayOfArrays); //var dicSer = BsonSerializer.LookupSerializer<Dictionary<string, object>>(); return(new BsonDocument { { MongoCommitFields.CheckpointNumber, checkpoint }, { MongoCommitFields.CommitId, commit.CommitId }, { MongoCommitFields.CommitStamp, commit.CommitStamp }, { MongoCommitFields.Headers, BsonDocumentWrapper.Create(commit.Headers) }, { MongoCommitFields.Events, new BsonArray(events) }, { MongoCommitFields.StreamRevisionFrom, streamRevisionStart }, { MongoCommitFields.StreamRevisionTo, streamRevision - 1 }, { MongoCommitFields.BucketId, commit.BucketId }, { MongoCommitFields.StreamId, commit.StreamId }, { MongoCommitFields.CommitSequence, commit.CommitSequence } }); }
public DocumentCreator(IFilePathProvider filePathProvider, IFileHandler fileHandler, IDocumentSerializer documentSerializer) { FilePathProvider = filePathProvider; FileHandler = fileHandler; DocumentSerializer = documentSerializer; }
public static BsonDocument ToMongoCommit(this CommitAttempt commit, Func <int> getNextCheckpointNumber, IDocumentSerializer serializer) { int streamRevision = commit.StreamRevision - (commit.Events.Count - 1); IEnumerable <BsonDocument> events = commit .Events .Select(e => new BsonDocument { { "StreamRevision", streamRevision++ }, { "Payload", new BsonDocumentWrapper(typeof(EventMessage), serializer.Serialize(e)) } }); return(new BsonDocument { { MongoFields.Id, new BsonDocument { { MongoFields.BucketId, commit.BucketId }, { MongoFields.StreamId, commit.StreamId }, { MongoFields.CommitSequence, commit.CommitSequence } } }, { MongoFields.CommitId, commit.CommitId }, { MongoFields.CommitStamp, commit.CommitStamp }, { MongoFields.CheckpointNumber, getNextCheckpointNumber() }, { MongoFields.Headers, BsonDocumentWrapper.Create(commit.Headers) }, { MongoFields.Events, new BsonArray(events) }, { MongoFields.Dispatched, false } }); }
public RedisDatabase(RedisConnection connection, IDocumentSerializer serializer, int databaseNumber) { Connection = connection; Serializer = serializer; Number = databaseNumber; }
public MongoPersistenceWireupFromConnectionString(Wireup inner, string connectionString, IDocumentSerializer serializer) : base(inner) { Logger.Debug("Configuring Mongo persistence engine."); Container.Register(c => new MongoPersistenceFactoryFromConnectionString(connectionString, serializer).Build()); }
public void SetUp() { serializer = new JsonDocumentSerializer(); }
public static PersistenceWireup UsingRavenPersistence( this Wireup wireup, string connectionName, IDocumentSerializer serializer, bool consistentQueries) { return new RavenPersistenceWireup(wireup, connectionName, serializer, consistentQueries); }
protected internal DocumentPartition(CloudStorageAccount storageAccount, string tableName, string partitionKey, Func <T, string> rowKey, IDocumentSerializer serializer) { TableName = tableName ?? DocumentPartition.GetDefaultTableName <T>(); PartitionKey = partitionKey ?? TablePartition.GetDefaultPartitionKey <T>(); repository = new DocumentRepository <T>(storageAccount, TableName, _ => PartitionKey, rowKey ?? RowKeyAttribute.CreateCompiledAccessor <T>(), serializer); }
public RavenPersistenceFactory(string connectionName, IDocumentSerializer serializer) : this(connectionName, serializer, false) { }
public static RavenSnapshot ToRavenSnapshot(this Snapshot snapshot, string partition, IDocumentSerializer serializer) { return(new RavenSnapshot { Id = ToRavenSnapshotId(snapshot, partition), Partition = partition, StreamId = snapshot.StreamId, StreamRevision = snapshot.StreamRevision, Payload = serializer.Serialize(snapshot.Payload) }); }
public static void SetDocumentSerializer(EventStoreConfiguration cfg, IDocumentSerializer serializer) { if (cfg.ContainsKey(DocumentSerializer_SettingsKey)) throw new InvalidOperationException("You should not configure document serializer for event store twice."); Condition.Requires(cfg, "cfg").IsNotNull(); Condition.Requires(serializer, "serializer").IsNotNull(); cfg.Set(DocumentSerializer_SettingsKey, serializer); }
public static PersistenceWireup UsingRavenPersistence( this Wireup wireup, string connectionName, IDocumentSerializer serializer) { return wireup.UsingRavenPersistence(connectionName, serializer, false); }
public static RavenCommit ToRavenCommit(this Commit commit, string partition, IDocumentSerializer serializer) { return(new RavenCommit { Id = ToRavenCommitId(commit, partition), Partition = partition, StreamId = commit.StreamId, CommitSequence = commit.CommitSequence, StartingStreamRevision = commit.StreamRevision - (commit.Events.Count - 1), StreamRevision = commit.StreamRevision, CommitId = commit.CommitId, CommitStamp = commit.CommitStamp, Headers = commit.Headers, Payload = serializer.Serialize(commit.Events) }); }
public SqlServerPersonRepository(EventStoreContext dbContext, SamplesContext samplesContext, IDocumentSerializer serializer, IAggregateFactory aggregateFactory) : base(dbContext, serializer, aggregateFactory) { _samplesContext = samplesContext; }
public SendEnvelopeHttpProcessorBase(HashSet <string> methods, UriTemplate template, IDocumentSerializer serializer, ITraceWriter traceWriter = null) { Methods = methods; Template = template; _serializer = serializer; _traceWriter = traceWriter; }
public MongoPersistenceFactory(Func<string> connectionStringProvider, IDocumentSerializer serializer, MongoPersistenceOptions options = null) { _connectionStringProvider = connectionStringProvider; _serializer = serializer; _options = options ?? new MongoPersistenceOptions(); }
public FormatConverter(IDocumentSerializer documentSerializer, InputParser inputParser) { _documentSerializer = documentSerializer; _inputParser = inputParser; }
public AesEncryptedDocumentSerializer(IDocumentSerializer internalSerializer, AesEncryptionOptions?options = null) { this.serializer = internalSerializer ?? throw new System.ArgumentNullException(nameof(internalSerializer)); this.options = options ?? new AesEncryptionOptions(); }
public AuthenticationContext(IFirebaseSettings settings, INetworkService networkService, IDocumentSerializer jsonSerializer) { _settings = settings; _networkService = networkService; _jsonSerializer = jsonSerializer; }
public virtual RavenPersistenceWireup WithSerializer(IDocumentSerializer instance) { this.serializer = instance; return this; }
public RedisClient(string connectionString, IDocumentSerializer serializer = null) : this(new RedisConfiguration(connectionString), serializer) { }
public static PersistenceWireup UsingMongoPersistenceFromConnectionString( this Wireup wireup, string connectionName, IDocumentSerializer serializer) { return new MongoPersistenceWireupFromConnectionString(wireup, connectionName, serializer); }
public FormatConverter() { _documentSerializer = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IDocumentSerializer>(); _inputParser = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <InputParser>(); }
public virtual RavenPersistenceWireup WithSerializer(IDocumentSerializer instance) { Logger.Debug("Registering serializer of type '{0}'.", instance.GetType()); this.serializer = instance; return this; }
public DocumentStoreInternal(IDocumentSerializer serializer, IDataStore dataStore) { this.rootDataStore = dataStore ?? throw new ArgumentNullException(nameof(dataStore)); this.serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); }
public RavenPersistenceFactory(string connectionName, IDocumentSerializer serializer, RavenPersistenceOptions options) { _options = options; _connectionName = connectionName; _serializer = serializer; }
public FormatConverter() { //_documentSerializer = new JsonDocumentSerializer(); _documentSerializer = new CamelCaseJsonSerializer(); _inputParser = new JsonInputParser(); }
public SendRawMessageAction(ISender sender, IDocumentSerializer documentSerializer) : base(nameof(SendRawMessage)) { _sender = sender; _documentSerializer = documentSerializer; }
public RavenPersistenceFactory(string connectionName, IDocumentSerializer serializer, bool consistentQueries) { this.ConnectionStringName = connectionName; this.serializer = serializer; this.consistentQueries = consistentQueries; }
protected ResourceVariableProviderBase(ISender sender, IDocumentSerializer documentSerializer, string resourceName) { _sender = sender; _documentSerializer = documentSerializer; _resourceName = resourceName ?? throw new ArgumentNullException(nameof(resourceName)); }
public ContactVariableProvider(IContactExtension contactExtension, IDocumentSerializer documentSerializer) : base(VariableSource.Contact, ContextExtensions.CONTACT_KEY) { _contactExtension = contactExtension; _documentSerializer = documentSerializer; }
public MongoPersistenceWireup(Wireup inner, Func <string> connectionStringProvider, IDocumentSerializer serializer, MongoPersistenceOptions persistenceOptions) : base(inner) { Logger.Debug("Configuring Mongo persistence engine."); #if !NETSTANDARD1_6 var options = Container.Resolve <TransactionScopeOption>(); if (options != TransactionScopeOption.Suppress) { Logger.Warn("MongoDB does not participate in transactions using TransactionScope."); } #endif Container.Register(_ => new MongoPersistenceFactory(connectionStringProvider, serializer, persistenceOptions).Build()); }