public Soundbox( IServiceProvider serviceProvider, IHubContext <SoundboxHub, ISoundboxClient> hubContext, ISoundboxConfigProvider config, IDatabaseProvider database, ISpeechRecognitionServiceProvider speechRecognitionServiceProvider, ILogger <Soundbox> logger, IOptions <SoundboxAppSettings> appSettings) { this.Logger = logger; logger.LogInformation("Soundbox is starting"); this.AppSettings = appSettings.Value ?? new SoundboxAppSettings(); this.ServiceProvider = serviceProvider; this.HubContext = hubContext; this.BaseDirectory = config.GetRootDirectory(); this.SoundsRootDirectory = this.BaseDirectory + "sounds/"; Directory.CreateDirectory(this.SoundsRootDirectory); this.Database = database; //initialize our file tree var taskSoundsRoot = LoadRoot(); taskSoundsRoot.Wait(); this.SoundsRoot = taskSoundsRoot.Result; BuildNodeCache(this.SoundsRoot); SpeechRecognition_Setup(speechRecognitionServiceProvider); }
public LiteDbPreferencesDatabaseProvider(ISoundboxConfigProvider config) { //open the database file var databaseDirectory = config.GetRootDirectory() + "database/"; Directory.CreateDirectory(databaseDirectory); Database = new LiteDatabase(databaseDirectory + "lite_preferences.db"); }
public LiteDbDatabaseProvider(ISoundboxConfigProvider config) { //prepare the bson document mapper BsonMapper = new BsonMapper(); BsonMapper.IncludeFields = true; BsonMapper.Entity <SoundboxNode>() .Id(f => f.ID, false); BsonMapper.Entity <SoundboxDirectory>() .DbRef(f => f.Children, COLLECTION_SOUNDS_NAME) .DbRef(f => f.ParentDirectory, COLLECTION_SOUNDS_NAME); BsonMapper.Entity <Sound>() .DbRef(f => f.ParentDirectory, COLLECTION_SOUNDS_NAME); BsonMapper.Entity <SoundMetaData>() .Ignore(m => m.HasLength); //open the database file var databaseDirectory = config.GetRootDirectory() + "database/"; Directory.CreateDirectory(databaseDirectory); Database = new LiteDatabase(databaseDirectory + "lite_sounds.db", BsonMapper); }
public SoundboxTestWrapper(IServiceProvider serviceProvider, IHubContext <SoundboxHub, ISoundboxClient> hubContext, ISoundboxConfigProvider config, IDatabaseProvider database) : base(serviceProvider, hubContext, config, database, null) { }