Esempio n. 1
0
        private static void TestAddSongRequest(IReadOnlyList <string> args)
        {
            var httpLink = ParseIntputLink(args);

            var settings = TestSettings.MockSettings(httpLink);

            using var scrapper = HttpWebScrapperFactory.Create(settings, Logger);

            scrapper.OpenUrl();

            var userData = UserData.Create("TestUserId", "TestUserName");
            var number   = SongRequestNumber.All;

            var request = SongRequestModel.CreateNew(userData, TestConfig.SongLink, number);

            request = request.AutoApprove(settings.AutoApproveReason);
            request = request.StartProcessing();
            var result = scrapper.Process(request);

            if (result.IsSuccess)
            {
                Logger.Info("Song request processed successfully!");
            }
            else
            {
                Logger.Error($"Failed to process song request: {result.Description}");
            }
        }
Esempio n. 2
0
        public void Destroy()
        {
            _isValid = false;
            try
            {
                OnDestroy?.Invoke(this);
            }
            catch (Exception e)
            {
                _logger.Error(e);
            }

            _timerManager.Destroy();
            _objectCache.Clear();
            _typeDB.Destroy();
            GC.Collect();
            CollectPendingGarbage();

            for (int i = 0, count = _contexts.Count; i < count; i++)
            {
                var context = _contexts[i];
                context.Destroy();
            }

            _contexts.Clear();

            if (_container != null)
            {
                Object.DestroyImmediate(_container);
                _container = null;
            }

            JSApi.JS_FreeRuntime(_rt);
            _rt = JSRuntime.Null;

            try
            {
                OnAfterDestroy?.Invoke(this);
            }
            catch (Exception e)
            {
                _logger.Error(e);
            }
        }