Example #1
0
        public static IMessageDataRepository Encrypted(this IMessageDataRepositorySelector selector, ICryptoStreamProvider streamProvider,
                                                       Func <IMessageDataRepositorySelector, IMessageDataRepository> innerSelector)
        {
            if (selector is null)
            {
                throw new ArgumentNullException(nameof(selector));
            }
            if (streamProvider is null)
            {
                throw new ArgumentNullException(nameof(streamProvider));
            }
            if (innerSelector == null)
            {
                throw new ArgumentNullException(nameof(innerSelector));
            }

            var innerRepository = innerSelector(selector);

            if (innerRepository is EncryptedMessageDataRepository)
            {
                throw new ArgumentException("Nesting encrypted repositories is not supported", nameof(innerSelector));
            }

            if (innerRepository is IBusObserver observer)
            {
                selector.Configurator.ConnectBusObserver(observer);
            }

            return(new EncryptedMessageDataRepository(innerRepository, streamProvider));
        }
Example #2
0
        public static IMessageDataRepository InMemory(this IMessageDataRepositorySelector selector)
        {
            if (selector is null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

            return(new InMemoryMessageDataRepository());
        }
Example #3
0
        public static IMessageDataRepository FileSystem(this IMessageDataRepositorySelector selector, string path)
        {
            if (selector is null)
            {
                throw new ArgumentNullException(nameof(selector));
            }
            if (path is null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            var dataDirectory = new DirectoryInfo(path);

            return(new FileSystemMessageDataRepository(dataDirectory));
        }
        /// <summary>
        /// Use MongoDB for message data storage, via GridFS
        /// </summary>
        /// <param name="selector"></param>
        /// <param name="connectionString"></param>
        /// <param name="containerName">Specify the container name (defaults to message-data)</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IMessageDataRepository MongoDb(this IMessageDataRepositorySelector selector, string connectionString,
                                                     string containerName = default)
        {
            if (selector is null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException(nameof(connectionString));
            }

            return(new MongoDbMessageDataRepository(connectionString, containerName ?? "message-data"));
        }
Example #5
0
        /// <summary>
        /// Use Azure Blob Storage for message data storage
        /// </summary>
        /// <param name="selector"></param>
        /// <param name="connectionString"></param>
        /// <param name="containerName">Specify the container name (defaults to message-data)</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IMessageDataRepository AzureStorage(this IMessageDataRepositorySelector selector, string connectionString, string containerName = default)
        {
            if (selector is null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException(nameof(connectionString));
            }

            var client = new BlobServiceClient(connectionString);

            var repository = client.CreateMessageDataRepository(containerName ?? "message-data");

            return(repository);
        }