示例#1
0
        ICancellationStrategy cancellationStrategy; // Aktuális cancel stratégia/viselkedés

        public DataProcessor(ICompressionStrategy compressionStrategy, ICancellationStrategy cancellationStrategy)
        {
            // Ügyelünk arra, hogy null-t nem fogadunk el, az osztály függőségeit kötelező megadni
            if (compressionStrategy == null)
            {
                throw new ArgumentNullException(nameof(compressionStrategy));
            }
            if (cancellationStrategy == null)
            {
                throw new ArgumentNullException(nameof(cancellationStrategy));
            }

            // Eltároljuk a paraméterként kapott stratégiákat
            this.compressionStrategy  = compressionStrategy;
            this.cancellationStrategy = cancellationStrategy;
        }
示例#2
0
        public CustomCancellationStrategy(string folderName, JsonRpc jsonRpc)
        {
            _folderName = folderName ?? throw new ArgumentNullException(nameof(folderName));
            _jsonRpc    = jsonRpc ?? throw new ArgumentNullException(nameof(jsonRpc));

            _cancellationFolderPath = Path.Combine(Path.GetTempPath(), "python-languageserver-cancellation", _folderName);

            _cancellationStrategy  = _jsonRpc.CancellationStrategy;
            _jsonRpc.Disconnected += OnDisconnected;

            try {
                Directory.CreateDirectory(_cancellationFolderPath);
            } catch (Exception e) when(!e.IsCriticalException())
            {
                // not much we can do about it.
            }
        }