public Downloader ()
		{
			var personal = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
			var dbpath = Path.Combine (personal, "download.db");
			var db = new SQLiteConnection (
				dbpath, 
				SQLiteOpenFlags.ReadWrite 
				| SQLiteOpenFlags.Create 
				| SQLiteOpenFlags.FullMutex , 
				true) {
				#if DEBUG
				Trace = true
				#endif
			};

			int maxdownloads = 3;
			_bus = new InProcessBus ();
			_repository = new DownloadRepository (db);
			_manager = new DownloadManager (_bus, _repository, maxdownloads);
			_service = new NSUrlSessionManager (_bus, maxdownloads);
			_progress = new ProgressManager (_bus, _repository);
			_timer = new Timer (TimerCallback, null, 1000, 1000);
			_timer = new Timer (TimerCallback, null, 1000, 1000);

			_bus.Subscribe<DownloadError> (DownloadError_Received);
			_bus.Subscribe<TaskError> (TaskError_Received);
			_bus.Subscribe<QueueEmpty> (QueueEmpty_Received);
			_bus.Subscribe<GlobalProgress> (GlobalProgress_Received);
			_bus.Subscribe<NotifyFinish> (NotifyFinish_Received);

		}
Esempio n. 2
0
        public Downloader()
        {
            var personal = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var dbpath   = Path.Combine(personal, "download.db");
            var db       = new SQLiteConnection(
                dbpath,
                SQLiteOpenFlags.ReadWrite
                | SQLiteOpenFlags.Create
                | SQLiteOpenFlags.FullMutex,
                true)
            {
                                #if DEBUG
                Trace = true
                                #endif
            };

            int maxdownloads = 3;

            _bus        = new InProcessBus();
            _repository = new DownloadRepository(db);
            _manager    = new DownloadManager(_bus, _repository, maxdownloads);
            _service    = new NSUrlSessionManager(_bus, maxdownloads);
            _progress   = new ProgressManager(_bus, _repository);
            _timer      = new Timer(TimerCallback, null, 1000, 1000);
            _timer      = new Timer(TimerCallback, null, 1000, 1000);

            _bus.Subscribe <DownloadError> (DownloadError_Received);
            _bus.Subscribe <TaskError> (TaskError_Received);
            _bus.Subscribe <QueueEmpty> (QueueEmpty_Received);
            _bus.Subscribe <GlobalProgress> (GlobalProgress_Received);
            _bus.Subscribe <NotifyFinish> (NotifyFinish_Received);
        }