/// <inheritdoc />
        public async Task <IMessageQueueingService> CreateMessageQueueingService(QueueingElement configuration)
        {
            var securityTokenServiceFactory = new SecurityTokenServiceFactory();
            var securitTokenConfig          = configuration.SecurityTokens;
            var securityTokenService        = await securityTokenServiceFactory.InitSecurityTokenService(securitTokenConfig);

            var path          = configuration.GetString("path");
            var sqliteBaseDir = GetRootedDirectory(path);

            var messageEncryptionServiceFactory = new MessageEncryptionServiceFactory();
            var messageEncryptionConfig         = configuration.Encryption;
            var messageEncryptionService        = await messageEncryptionServiceFactory.InitMessageEncryptionService(messageEncryptionConfig);

            var queueingOptions = new SQLiteMessageQueueingOptions
            {
                BaseDirectory            = sqliteBaseDir,
                SecurityTokenService     = securityTokenService,
                MessageEncryptionService = messageEncryptionService
            };

            var sqliteMessageQueueingService = new SQLiteMessageQueueingService(queueingOptions);

            sqliteMessageQueueingService.Init();
            return(sqliteMessageQueueingService);
        }
        /// <inheritdoc />
        public async Task <IMessageQueueingService> CreateMessageQueueingService(IConfiguration configuration)
        {
            var securityTokenServiceFactory = new SecurityTokenServiceFactory();
            var securityTokensSection       = configuration?.GetSection("securityTokens");
            var securityTokenService        = await securityTokenServiceFactory.InitSecurityTokenService(securityTokensSection);

            var path          = configuration?["path"];
            var sqliteBaseDir = GetRootedDirectory(path);

            var messageEncryptionServiceFactory = new MessageEncryptionServiceFactory();
            var messageEncryptionConfig         = configuration?.GetSection("encryption");
            var messageEncryptionService        = await messageEncryptionServiceFactory.InitMessageEncryptionService(messageEncryptionConfig);

            var queueingOptions = new SQLiteMessageQueueingOptions
            {
                BaseDirectory            = sqliteBaseDir,
                SecurityTokenService     = securityTokenService,
                MessageEncryptionService = messageEncryptionService
            };

            var sqliteMessageQueueingService = new SQLiteMessageQueueingService(queueingOptions);

            sqliteMessageQueueingService.Init();
            return(sqliteMessageQueueingService);
        }
        /// <summary>
        /// Initializes a new <see cref="SQLiteMessageQueueingService"/>
        /// </summary>
        /// <param name="options">(Optional) Options that influence the behavior of this service</param>
        /// <remarks>
        /// <para>If a base directory is not specified then the base directory will default to a
        /// directory named <c>platibus\queues</c> beneath the current app domain base
        /// directory.  If the base directory does not exist it will be created.</para>
        /// <para>If a security token service is not specified then a default implementation based
        /// on unsigned JWTs will be used.</para>
        /// </remarks>
        public SQLiteMessageQueueingService(SQLiteMessageQueueingOptions options)
        {
            DiagnosticService = options?.DiagnosticService ?? Diagnostics.DiagnosticService.DefaultInstance;
            var baseDirectory = options?.BaseDirectory;

            if (baseDirectory == null)
            {
                var appdomainDirectory = AppDomain.CurrentDomain.BaseDirectory;
                baseDirectory = new DirectoryInfo(Path.Combine(appdomainDirectory, "platibus", "queues"));
            }
            _baseDirectory            = baseDirectory;
            _securityTokenService     = options?.SecurityTokenService ?? new JwtSecurityTokenService();
            _messageEncryptionService = options?.MessageEncryptionService;
        }