Beispiel #1
0
        public void CreateDatasourceTest()
        {
            IBdoLog log        = new BdoLog();
            var     datasource = ItemFactory.CreateDatasource("name", DatasourceKind.Database)
                                 .WithConfiguration(
                (GlobalVariables.Scope?.CreateConnectorConfiguration("tests.core$test", log)
                 as BdoConnectorConfiguration)?.WithConnectionString("connectionString"));

            Assert.That(
                datasource != null, "Bad data source creation");
        }
        /// <summary>
        /// Creates the specified PostgreSql data source.
        /// </summary>
        /// <param name="datasourceDepot"></param>
        /// <param name="name"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        public static Datasource CreatePostgreSqlDatasource(
            this IBdoDatasourceDepot datasourceDepot,
            string name,
            string connectionString,
            IBdoLog log = null)
        {
            var datasource = ItemFactory.CreateDatasource(name, DatasourceKind.Database)
                             .WithConfiguration(
                (datasourceDepot?.Scope?.CreateConnectorConfiguration("databases.postgresql$client", log)
                 as BdoConnectorConfiguration)?.WithConnectionString(connectionString));

            return(datasource as Datasource);
        }
        /// <summary>
        /// Adds sources from host.
        /// </summary>
        /// <param name="depot">The datasource depot to consider.</param>
        /// <param name="config">The configuration to consider.</param>
        /// <param name="keyName">The key name to consider.</param>
        public static IBdoDatasourceDepot AddFromNetCoreConfiguration(this IBdoDatasourceDepot depot, IConfiguration config, string keyName = "connectionStrings")
        {
            if (depot != null && config != null)
            {
                var sections = config.GetSection(keyName).GetChildren();
                foreach (var section in sections)
                {
                    depot.Add(
                        ItemFactory.CreateDatasource(section.Key, DatasourceKind.Database)
                        .WithConfiguration(
                            new BdoConnectorConfiguration().WithConnectionString(section.Value) as BdoConnectorConfiguration)
                        );
                }
            }
            ;

            return(depot);
        }
        public void CreateDatasourceDataStoreTest()
        {
            var config =
                BdoExtensionFactory.CreateConnectorConfiguration("messages$smtp")
                .WithItems(
                    ElementFactory.CreateScalar("host", _testData.host),
                    ElementFactory.CreateScalar("port", DataValueTypes.Integer, _testData.port),
                    ElementFactory.CreateScalar("isDefaultCredentialsUsed", DataValueTypes.Boolean, _testData.isDefaultCredentialsUsed),
                    ElementFactory.CreateScalar("isSslEnabled", DataValueTypes.Boolean, _testData.isSslEnabled),
                    ElementFactory.CreateScalar("timeout", DataValueTypes.Integer, _testData.timeout),
                    ElementFactory.CreateScalar("login", _testData.login),
                    ElementFactory.CreateScalar("password", _testData.password));

            _datasourceDepot = ItemFactory.CreateSet <BdoDatasourceDepot, IDatasource>(
                ItemFactory.CreateDatasource("smtp_default", DatasourceKind.EmailServer)
                .WithConfiguration(config));

            TestDatasourceDataStore(_datasourceDepot);
        }