Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Configuration"/> class.
        /// </summary>
        /// <param name="configurationWrapper"><see cref="IConfigurationFor{T}"/> <see cref="ReadModelRepositoryConfiguration"/>.</param>
        public Configuration(IConfigurationFor <ReadModelRepositoryConfiguration> configurationWrapper)
        {
            var config = configurationWrapper.Instance;

            if (string.IsNullOrEmpty(config.ConnectionString))
            {
                var s = MongoClientSettings.FromUrl(new MongoUrl(config.Host));
                if (config.UseSSL)
                {
                    s.UseSsl      = true;
                    s.SslSettings = new SslSettings
                    {
                        EnabledSslProtocols        = System.Security.Authentication.SslProtocols.Tls12,
                        CheckCertificateRevocation = false
                    };
                }

                Client = new MongoClient(s);
            }
            else
            {
                Client = new MongoClient(config.ConnectionString);
            }

            Database = Client.GetDatabase(config.Database);

            BsonSerializer.RegisterSerializationProvider(new ConceptSerializationProvider());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Instantiates an instance of <see cref="Connection"/>
        /// </summary>
        public Connection(IConfigurationFor <EventStoreConfiguration> configurationWrapper)
        {
            var config = configurationWrapper.Instance;

            if (string.IsNullOrEmpty(config.ConnectionString))
            {
                var s = MongoClientSettings.FromUrl(new MongoUrl(config.Host));
                if (config.UseSSL)
                {
                    s.UseSsl      = true;
                    s.SslSettings = new SslSettings
                    {
                        EnabledSslProtocols        = System.Security.Authentication.SslProtocols.Tls12,
                        CheckCertificateRevocation = false
                    };
                }
                Server = new MongoClient(s);
            }
            else
            {
                Server = new MongoClient(config.ConnectionString);
            }

            Database = Server.GetDatabase(config.Database);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of <see cref="Files"/>
 /// </summary>
 /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> to use for determining the current tenant</param>
 /// <param name="configuration"><see cref="FilesConfiguration">Configuration</see></param>
 /// <param name="fileSystem">Underlying <see cref="IFileSystem"/></param>
 public Files(
     IExecutionContextManager executionContextManager,
     IConfigurationFor <FilesConfiguration> configuration,
     IFileSystem fileSystem)
 {
     _executionContextManager = executionContextManager;
     _fileSystem    = fileSystem;
     _configuration = configuration.Instance;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BootProcedure"/> class.
        /// </summary>
        /// <param name="container">The <see cref="IContainer"/>.</param>
        /// <param name="executionContextManager">The <see cref="IExecutionContextManager"/> for managing <see cref="ExecutionContext"/>.</param>
        /// <param name="jsRuntime">The <see cref="IJSRuntime"/>.</param>
        public BootProcedure(
            IContainer container,
            IExecutionContextManager executionContextManager,
            IJSRuntime jsRuntime)
        {
            _jsRuntime = jsRuntime;

            executionContextManager.CurrentFor(TenantId.Development);
            _configurationFor = container.Get <IConfigurationFor <Configuration> >();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of <see cref="MiniMongoDatabase"/>
        /// </summary>
        /// <param name="configurationFor"></param>
        /// <param name="jsRuntime"></param>
        /// <param name="logger"></param>
        public MiniMongoDatabase(
            IConfigurationFor <Configuration> configurationFor,
            IJSRuntime jsRuntime,
            ILogger logger)

        {
            _configuration = configurationFor;
            _jsRuntime     = jsRuntime;
            _jsRuntime.Invoke($"{_globalObject}.initialize", configurationFor.Instance.Database);
            _logger = logger;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of <see cref="MiniMongoDatabase"/>
 /// </summary>
 /// <param name="collectionName"></param>
 /// <param name="configurationFor"></param>
 /// <param name="jsRuntime"></param>
 /// <param name="logger"></param>
 public MiniMongoCollection(
     string collectionName,
     IConfigurationFor <Configuration> configurationFor,
     IJSRuntime jsRuntime,
     ILogger logger)
 {
     _configuration  = configurationFor.Instance;
     _collectionName = collectionName;
     _jsRuntime      = jsRuntime;
     _logger         = logger;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MiniMongoDatabase"/> class.
 /// </summary>
 /// <param name="configurationFor"><see cref="Configuration"/>.</param>
 /// <param name="jsRuntime">The <see cref="IJSRuntime"/>.</param>
 /// <param name="serializer">JSON <see cref="ISerializer"/>.</param>
 /// <param name="logger"><see cref="ILogger"/> for logging.</param>
 public MiniMongoDatabase(
     IConfigurationFor <Configuration> configurationFor,
     IJSRuntime jsRuntime,
     ISerializer serializer,
     ILogger logger)
 {
     _configuration = configurationFor;
     _jsRuntime     = jsRuntime;
     _serializer    = serializer;
     _logger        = logger;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DatabaseConnection"/> class.
        /// </summary>
        /// <param name="configuration">A <see cref="IConfigurationFor{EventStoreConfiguration}"/> with database connection parameters.</param>
        public DatabaseConnection(IConfigurationFor <EventStoreConfiguration> configuration)
        {
            var config   = configuration.Instance;
            var settings = new MongoClientSettings
            {
                Servers            = config.Servers.Select(_ => new MongoServerAddress(_)),
                GuidRepresentation = GuidRepresentation.Standard
            };

            MongoClient = new MongoClient(settings.Freeze());
            Database    = MongoClient.GetDatabase(config.Database);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="configFor"></param>
        /// <param name="logger"></param>
        /// <param name="executionContextManager"></param>
        public EventStoreAzureDbConfiguration(IConfigurationFor <EventStoreConfiguration> configFor, ILogger logger, IExecutionContextManager executionContextManager)
        {
            Logger = logger;
            _executionContextManager = executionContextManager;
            var config = configFor.Instance;

            EndpointUrl      = config.EndPointUrl;
            DatabaseId       = config.DatabaseId;
            AuthorizationKey = config.AuthKey;
            _collections     = new List <DocumentCollection>();
            Client           = new DocumentClient(new Uri(EndpointUrl), AuthorizationKey);
            BasePartitionKey =
                $"{executionContextManager.Current.Application}_{executionContextManager.Current.BoundedContext}_{executionContextManager.Current.Tenant}";
            Bootstrap();
        }
Exemplo n.º 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="configuration"></param>
 public EventStoreConnector(IConfigurationFor <EventStoreConfiguration> configuration)
 {
     _configuration = configuration.Instance;
     _connection    = EventStoreConnection.Create(_configuration.ConnectionString);
     _connectTask   = _connection.ConnectAsync();
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of <see cref="MongoCollectionProxy{T}"/>
 /// </summary>
 /// <param name="configuration"><see cref="Configuration"/> to use</param>
 public MongoCollectionProxy(IConfigurationFor <Configuration> configuration)
 {
     _configuration    = configuration.Instance;
     _actualCollection = _configuration.Database.GetCollection <T>(typeof(T).Name);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of <see cref="MongoDatabaseProxy"/>
 /// </summary>
 /// <param name="configuration"><see cref="Configuration"/> to use</param>
 public MongoDatabaseProxy(IConfigurationFor <Configuration> configuration)
 {
     _configuration = configuration.Instance;
 }