示例#1
0
        public IDataStore GetProjectDataStore(ProjectSettings projectSettings)
        {
            DataStoreOptions projectStoreOptions = options.Store[projectSettings.StoreName];

            switch (projectStoreOptions.DataBase)
            {
            case "sqlserver":
                return(new SqlServerDataStore(
                           projectSettings.Name,
                           projectStoreOptions.Host,
                           projectStoreOptions.Port,
                           projectStoreOptions.User,
                           projectStoreOptions.Password));

            case "postgresql":
                return(new PostgreSqlDataStore(
                           projectSettings.Name,
                           projectStoreOptions.Host,
                           projectStoreOptions.Port,
                           projectStoreOptions.User,
                           projectStoreOptions.Password));

            default:
                throw new ArgumentException(nameof(projectStoreOptions.DataBase));
            }
        }
示例#2
0
        public DataStore(DataStoreOptions options)
        {
            var databaseFile = options.DatabaseFile;
            var schemaFile   = options.SchemaFile;

            if (String.IsNullOrEmpty(databaseFile))
            {
                throw new ArgumentException("Database name is not specified");
            }

            if (String.IsNullOrEmpty(schemaFile))
            {
                throw new ArgumentException("Schema file is not specified");
            }

            if (options == null)
            {
                options = new DataStoreOptions();
            }

            // Put in the current directory if it's not an absolute path
            schemaFile = ResolvePath(schemaFile);

            if (!File.Exists(schemaFile))
            {
                throw new ArgumentException(String.Format("Schema file does not exist at {0}", schemaFile), "schemaFile");
            }

            // Automatically append a suffix if there isn't one
            if (!Path.HasExtension(databaseFile))
            {
                databaseFile += databaseFileExtension;
            }

            // Put in the current directory if it's not an absolute path
            databaseFile = ResolvePath(databaseFile);

            this.dbFile     = databaseFile;
            this.schemaFile = schemaFile;
            this.options    = options;
        }