Example #1
0
        private ITelemetryDataStore <IDictionary <string, object> > CreateDataStore(IConfiguration configuration)
        {
            ITelemetryDataStore <IDictionary <string, object> > dataStore = null;
            IConfigurationSection datastoreSettings = configuration
                                                      .GetSection(Startup.DataStoresSection);

            string useDataStore = datastoreSettings.GetValue <string>(Startup.UseStoreSetting);

            if (useDataStore == Startup.MySqlSection)
            {
                // Use Firebase Data Store
                IConfigurationSection mySqlSettings = datastoreSettings.GetSection(Startup.MySqlSection);
                string connectionString             = mySqlSettings.GetValue <string>(Startup.ConnectionStringSetting);

                dataStore = new SqlTelemetryDataStore <IDictionary <string, object> >(connectionString);
            }
            else if (useDataStore == Startup.FileSystemSection)
            {
                // Use File System Data Store
                IConfigurationSection fileSystemSettings = datastoreSettings.GetSection(Startup.FileSystemSection);

                dataStore = new FileSystemTelemetryDataStore <IDictionary <string, object> >(
                    new DirectoryInfo(fileSystemSettings.GetValue <string>(Startup.StorageDirectorySetting)));
            }

            return(dataStore);
        }
 public TelemetryController(ITelemetryDataStore <IDictionary <string, object> > dataStore)
 {
     this.DataStore = dataStore
                      ?? throw new ArgumentException("The data store parameter is required.", nameof(dataStore));
 }