public static void Main(string[] args)
        {
            IConfiguration config = LoadConfiguration();

            applicationSettings = new ApplicationSettings();
            cacheSettings       = new CacheSettings();
            dataStoreSettings   = new DataStoreSettings();
            nuciLoggerSettings  = new NuciLoggerSettings();

            config.Bind(nameof(ApplicationSettings), applicationSettings);
            config.Bind(nameof(CacheSettings), cacheSettings);
            config.Bind(nameof(DataStoreSettings), dataStoreSettings);
            config.Bind(nameof(NuciLoggerSettings), nuciLoggerSettings);

            IServiceProvider serviceProvider = new ServiceCollection()
                                               .AddSingleton(applicationSettings)
                                               .AddSingleton(cacheSettings)
                                               .AddSingleton(dataStoreSettings)
                                               .AddSingleton(nuciLoggerSettings)
                                               .AddSingleton <ICacheManager, CacheManager>()
                                               .AddSingleton <IDnsResolver, DnsResolver>()
                                               .AddSingleton <IFileDownloader, FileDownloader>()
                                               .AddSingleton <IPlaylistAggregator, PlaylistAggregator>()
                                               .AddSingleton <IPlaylistFetcher, PlaylistFetcher>()
                                               .AddSingleton <IPlaylistFileBuilder, PlaylistFileBuilder>()
                                               .AddSingleton <IChannelMatcher, ChannelMatcher>()
                                               .AddSingleton <IMediaSourceChecker, MediaSourceChecker>()
                                               .AddSingleton <IRepository <ChannelDefinitionEntity> >(s => new XmlRepository <ChannelDefinitionEntity>(dataStoreSettings.ChannelStorePath))
                                               .AddSingleton <IRepository <GroupEntity> >(s => new XmlRepository <GroupEntity>(dataStoreSettings.GroupStorePath))
                                               .AddSingleton <IRepository <PlaylistProviderEntity> >(s => new XmlRepository <PlaylistProviderEntity>(dataStoreSettings.PlaylistProviderStorePath))
                                               .AddSingleton <ILogger, NuciLogger>()
                                               .BuildServiceProvider();

            ILogger logger = serviceProvider.GetService <ILogger>();

            logger.Info(Operation.StartUp, OperationStatus.Success);

            try
            {
                IPlaylistAggregator aggregator = serviceProvider.GetService <IPlaylistAggregator>();

                string playlistFile = aggregator.GatherPlaylist();
                File.WriteAllText(applicationSettings.OutputPlaylistPath, playlistFile);
            }
            catch (AggregateException ex)
            {
                foreach (Exception innerException in ex.InnerExceptions)
                {
                    logger.Fatal(Operation.Unknown, OperationStatus.Failure, innerException);
                }
            }
            catch (Exception ex)
            {
                logger.Fatal(Operation.Unknown, OperationStatus.Failure, ex);
            }

            logger.Info(Operation.ShutDown, OperationStatus.Success);
        }
Exemple #2
0
        public ProductRepository(IOptions <DataStoreSettings> options)
        {
            DataStoreSettings dataStoreSettings = options.Value;

            _mySqlConnectionStringBuilder = new MySqlConnectionStringBuilder
            {
                Server   = dataStoreSettings.Server,
                Database = dataStoreSettings.Database,
                UserID   = dataStoreSettings.UserId,
                Password = dataStoreSettings.Password
            };
        }
        public static IServiceCollection AddConfigurations(this IServiceCollection services, IConfiguration configuration)
        {
            dataStoreSettings = new DataStoreSettings();
            telegramSettings  = new TelegramSettings();
            loggingSettings   = new NuciLoggerSettings();

            configuration.Bind(nameof(DataStoreSettings), dataStoreSettings);
            configuration.Bind(nameof(TelegramSettings), telegramSettings);
            configuration.Bind(nameof(NuciLoggerSettings), loggingSettings);

            services.AddSingleton(dataStoreSettings);
            services.AddSingleton(telegramSettings);
            services.AddSingleton(loggingSettings);

            return(services);
        }
Exemple #4
0
 public AsyncController(IDataStore ds, JobsService jobs, IOptions <DataStoreSettings> dsSettings)
 {
     _ds         = ds;
     _jobs       = jobs;
     _dsSettings = dsSettings.Value;
 }
 public DynamicController(IDataStore ds, IOptions <ApiSettings> apiSettings, IOptions <DataStoreSettings> dsSettings)
 {
     _ds          = ds;
     _apiSettings = apiSettings.Value;
     _dsSettings  = dsSettings.Value;
 }
 public HelloWorldService(ILogger <HelloWorldService> logger, DataStoreSettings dataStoreSettings, IDataStoreFactory dataStoreFactory)
 {
     _logger            = logger;
     _dataStoreSettings = dataStoreSettings;
     _dataStoreFactory  = dataStoreFactory;
 }