void StartCurrentConfig()
        {
            ScanDelegate scanDelegate = Scanner.Factory.GetScanner().Scan;

            //UpdateStatusBar(true, Resources.AppName, _filesProcessed, _totalFiles);

            var handler = Started;

            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }

            ScanStopper stopper = () => _stopPending;

            IsRunning = true;
            scanDelegate.BeginInvoke(
                _projectsToScan[_currentProject].FilesToScan,
                _projectsToScan[_currentProject].SearchingWord,
                new FileScanCompleted(ScanResultRecieved),
                new FileContentGetter(GetTextOfFileIfOpenInIde),
                stopper,
                ScanCompleted,
                null /* 'object' argument */);
        }
Пример #2
0
        /// <summary>
        /// Starts a scanner
        /// </summary>
        public void StartScanner(ScannerBase scannerName)
        {
            currentScanner = scannerName;

            System.Reflection.MethodInfo mi = scannerName.GetType().GetMethod("Scan", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
            ScanDelegate objScan            = (ScanDelegate)Delegate.CreateDelegate(typeof(ScanDelegate), mi);

            Main.Logger.WriteLine("Starting scanning: " + scannerName.ScannerName);

            // Update section name
            scannerName.RootNode.SectionName = scannerName.ScannerName;
            scannerName.RootNode.Img         = this.imageList.Images[scannerName.GetType().Name];
            ScanDlg.CurrentSection           = scannerName.ScannerName;

            // Start scanning
            this.threadScan = new Thread(new ThreadStart(objScan));
            this.threadScan.Start();
            this.threadScan.Join();

            // Wait 250ms
            Thread.Sleep(250);

            if (scannerName.RootNode.Nodes.Count > 0)
            {
                ScanDlg.arrBadRegistryKeys.Add(scannerName.RootNode);
            }

            Main.Logger.WriteLine("Finished scanning: " + scannerName.ScannerName);
            Main.Logger.WriteLine();

            this.progressBar.Position++;
            SetProgressValue(this.progressBar.Position, ScanDlg.arrBadRegistryKeys.SectionCount);
        }
        void StartCurrentConfig()
        {
            ScanDelegate scanDelegate = CodeSweep.Scanner.Factory.GetScanner().Scan;

            List <ITermTable> termTables = new List <ITermTable>();

            foreach (string tableFile in _projectsToScan[_currentProject].TermTableFiles)
            {
                try
                {
                    termTables.Add(CodeSweep.Scanner.Factory.GetTermTable(tableFile));
                }
                catch (Exception ex)
                {
                    if (!(ex is ArgumentException || ex is System.Xml.XmlException))
                    {
                        throw;
                    }
                }
            }

            UpdateStatusBar(true, Resources.AppName, _filesProcessed, _totalFiles);

            var handler = Started;

            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }

            ScanStopper stopper = () => _stopPending;

            IsRunning = true;
            scanDelegate.BeginInvoke(
                _projectsToScan[_currentProject].FilesToScan,
                termTables,
                new FileScanCompleted(ScanResultRecieved),
                new FileContentGetter(GetTextOfFileIfOpenInIde),
                stopper,
                ScanCompleted,
                null /* 'object' argument */);
        }
Пример #4
0
        /// <summary>
        /// Starts a scanner
        /// </summary>
        public static void StartScanner(ScannerBase scannerName)
        {
            currentScanner = scannerName;

            System.Reflection.MethodInfo mi = scannerName.GetType().GetMethod("Scan", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
            ScanDelegate objScan            = (ScanDelegate)Delegate.CreateDelegate(typeof(ScanDelegate), mi);


            // Update section name
            scannerName.RootNode.SectionName = scannerName.ScannerName;
            ScannerFunctions.CurrentSection  = scannerName.ScannerName;

            // Start scanning
            threadScan = new Thread(new ThreadStart(objScan));
            threadScan.Start();
            threadScan.Join();

            // Wait 250ms
            Thread.Sleep(250);

            ScannerFunctions.arrBadRegistryKeys.Add(scannerName.RootNode);
        }
Пример #5
0
 public CompiledRegexRunner(ScanDelegate scan)
 {
     _scanMethod = scan;
 }
Пример #6
0
 public CompiledRegexRunner(ScanDelegate scan, CultureInfo?culture)
 {
     _scanMethod = scan;
     _culture    = culture;
 }
Пример #7
0
        /// <summary>
        /// Ends the scan.
        /// </summary>
        /// <param name="result">The result.</param>
        public void EndScan(IAsyncResult result)
        {
            if (result == null)
                throw new ArgumentNullException("asyncResult");

            if (_scanDelegate == null)
                throw new InvalidOperationException("A async scan was never started.");

            try
            {
                _scanDelegate.EndInvoke(result);
            }
            finally
            {
                _scanDelegate = null;
                _asyncActiveEvent.Set();

                if ((this._asyncActiveEvent != null) && (Interlocked.Decrement(ref this._asyncActiveCount) == 0))
                {
                    this._asyncActiveEvent.Close();
                    this._asyncActiveEvent = null;
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Begins the scan.
        /// </summary>
        /// <param name="callback">The callback.</param>
        /// <param name="state">The state.</param>
        /// <returns></returns>
        public IAsyncResult BeginScan(AsyncCallback callback, object state)
        {
            Interlocked.Increment(ref this._asyncActiveCount);
            ScanDelegate scanDelegate = new ScanDelegate(this.Scan);

            if (_asyncActiveEvent == null)
            {
                lock (this)
                {
                    if (_asyncActiveEvent == null)
                        _asyncActiveEvent = new AutoResetEvent(true);
                }
            }

            _asyncActiveEvent.WaitOne();
            _scanDelegate = scanDelegate;

            return scanDelegate.BeginInvoke(callback, state);
        }