/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; if (FileId != null) { hashCode = hashCode * 59 + FileId.GetHashCode(); } if (PageRange != null) { hashCode = hashCode * 59 + PageRange.GetHashCode(); } hashCode = hashCode * 59 + RoiLeft.GetHashCode(); hashCode = hashCode * 59 + RoiTop.GetHashCode(); hashCode = hashCode * 59 + RoiWidth.GetHashCode(); hashCode = hashCode * 59 + RoiHeight.GetHashCode(); hashCode = hashCode * 59 + ScanMode.GetHashCode(); hashCode = hashCode * 59 + ScanBarcode1D.GetHashCode(); hashCode = hashCode * 59 + ScanBarcodeQR.GetHashCode(); hashCode = hashCode * 59 + ScanBarcodeMicroQR.GetHashCode(); hashCode = hashCode * 59 + ScanBarcodePDF417.GetHashCode(); hashCode = hashCode * 59 + ScanBarcodeDataMatrix.GetHashCode(); hashCode = hashCode * 59 + ScanBarcodeAztec.GetHashCode(); return(hashCode); } }
/// <summary> /// Scan task /// </summary> /// <param name="mode"></param> /// <param name="cancellationToken"></param> /// <returns></returns> private void Scan(ScanMode mode, CancellationToken cancellationToken) { // Main loop while (!cancellationToken.IsCancellationRequested) { // Try to start lidar if (!StartLidar(mode)) { // Reset and try to start again in a while to avoid high CPU load if something breaks lidar.Reset(); Thread.Sleep(1000); continue; } // Run lidar if (!RunLidar(cancellationToken)) { // Reset and try to start again lidar.Reset(); continue; } } // Stop lidar StopLidar(); }
public RawMessageBuilder(int maxMessageSize) { _rawMessage = new RawMessage(maxMessageSize); _workBuffer = new MemoryStream(maxMessageSize); _workBuffer.SetLength(maxMessageSize); _mode = ScanMode.ReadHeader; }
public static AndroidScanMode ToNative(this ScanMode scanMode) { if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop) { throw new InvalidOperationException("Scan modes are not implemented in API lvl < 21."); } switch (scanMode) { case ScanMode.Passive: if (Build.VERSION.SdkInt < BuildVersionCodes.M) { Trace.Message("Scanmode Passive is not supported on API lvl < 23. Falling back to LowPower."); return(AndroidScanMode.LowPower); } return(AndroidScanMode.Opportunistic); case ScanMode.LowPower: return(AndroidScanMode.LowPower); case ScanMode.Balanced: return(AndroidScanMode.Balanced); case ScanMode.LowLatency: return(AndroidScanMode.LowLatency); default: throw new ArgumentOutOfRangeException(nameof(scanMode), scanMode, null); } }
private T4TokenNodeType ScanAttributeValue() { if (_buffer[_pos] == '"') { ++_pos; _scanMode = ScanMode.Directive; return(T4TokenNodeTypes.Quote); } ++_pos; while (_pos < _length && !IsCurrentCharTag()) { switch (_buffer[_pos]) { case '"': return(T4TokenNodeTypes.Value); case '\\': if (_pos + 1 < _length && _buffer[_pos + 1] == '"') { ++_pos; } break; } ++_pos; } return(T4TokenNodeTypes.Value); }
/// <summary> /// Starts lexing the whole buffer. /// </summary> public void Start() { _pos = 0; _length = _buffer.Length; _scanMode = ScanMode.Text; _currentTokenType = null; }
private void GetDirectoryStructure(string path, ScanMode mode) { try { foreach (string d in System.IO.Directory.GetDirectories(path)) { CurrentDirectory?.Invoke(path); if (mode == ScanMode.AnalyseDirectoryStructure) { this.analyseDirectoryCount += 1; UpdateDirectories?.Invoke(this.analyseDirectoryCount.ToString()); } else { this.scanDirectoryCount += 1; UpdateDirectories?.Invoke(this.scanDirectoryCount + " of " + this.analyseDirectoryCount); } GetFiles(d, mode); GetDirectoryStructure(d, mode); } } catch (UnauthorizedAccessException ex) { } }
public ScanResult Scan(string fileName, ScanMode scanMode) { using (FileStream file = new FileStream(fileName,FileMode.Open,FileAccess.Read)) { return Scan(file,scanMode); } }
public IActionResult MainScanPage(long storeId, string stockNo = null, ScanMode mode = ScanMode.StockIn) { ViewBag.StoreId = storeId; ViewBag.StockNo = stockNo; ViewBag.ScanMode = mode; return(View()); }
private void GetFiles(string filePath, ScanMode mode) { try { foreach (string str in System.IO.Directory.GetFiles(filePath)) { System.IO.FileInfo fi = new System.IO.FileInfo(str); if (!this.itemsList.Contains(fi.Extension.ToUpper())) { continue; } if (mode == ScanMode.AnalyseDirectoryStructure) { this.analyseFileCount += 1; UpdateFiles?.Invoke(this.analyseFileCount.ToString()); } else { this.scanFileCount += 1; UpdateFiles?.Invoke(this.scanFileCount + " of " + this.analyseFileCount); UpdateProgress?.Invoke(Convert.ToInt32((this.scanFileCount / (double)this.analyseFileCount) * 100)); ScanFile(str); } } } catch (UnauthorizedAccessException ex) { } }
private void StartScanningNew(Guid[] serviceUuids) { var hasFilter = serviceUuids?.Any() ?? false; List <ScanFilter> scanFilters = null; if (hasFilter) { scanFilters = new List <ScanFilter>(); foreach (var serviceUuid in serviceUuids) { var sfb = new ScanFilter.Builder(); sfb.SetServiceUuid(ParcelUuid.FromString(serviceUuid.ToString())); scanFilters.Add(sfb.Build()); } } var ssb = new ScanSettings.Builder(); ssb.SetScanMode(ScanMode.ToNative()); //ssb.SetCallbackType(ScanCallbackType.AllMatches); if (_bluetoothAdapter.BluetoothLeScanner != null) { Trace.Message($"Adapter >=21: Starting a scan for devices. ScanMode: {ScanMode}"); if (hasFilter) { Trace.Message($"ScanFilters: {string.Join(", ", serviceUuids)}"); } _bluetoothAdapter.BluetoothLeScanner.StartScan(scanFilters, ssb.Build(), _api21ScanCallback); } else { Trace.Message("Adapter >= 21: Scan failed. Bluetooth is probably off"); } }
protected override async Task InitializeAsync() { await base.InitializeAsync(); // BLE requires location permissions if (await SensusServiceHelper.Get().ObtainPermissionAsync(Permission.Location) != PermissionStatus.Granted) { // throw standard exception instead of NotSupportedException, since the user might decide to enable location in the future // and we'd like the probe to be restarted at that time. string error = "Geolocation is not permitted on this device. Cannot start Bluetooth probe."; await SensusServiceHelper.Get().FlashNotificationAsync(error); throw new Exception(error); } _deviceIdCharacteristic = new BluetoothGattCharacteristic(UUID.FromString(DEVICE_ID_CHARACTERISTIC_UUID), GattProperty.Read, GattPermission.Read); _deviceIdCharacteristic.SetValue(Encoding.UTF8.GetBytes(SensusServiceHelper.Get().DeviceId)); _deviceIdService = new BluetoothGattService(UUID.FromString(Protocol.Id), GattServiceType.Primary); _deviceIdService.AddCharacteristic(_deviceIdCharacteristic); _bluetoothAdvertiserCallback = new AndroidBluetoothServerAdvertisingCallback(_deviceIdService, _deviceIdCharacteristic); if (ScanMode.HasFlag(BluetoothScanModes.Classic)) { _bluetoothBroadcastReceiver = new AndroidBluetoothDeviceReceiver(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.AddAction(BluetoothDevice.ActionFound); Application.Context.RegisterReceiver(_bluetoothBroadcastReceiver, intentFilter); } }
/// <summary> /// Starts lexing a part of the buffer. /// </summary> /// <param name="startOffset">The starting offset.</param> /// <param name="endOffset">The ending offset.</param> /// <param name="state">The scan mode of the lexer.</param> public void Start(int startOffset, int endOffset, uint state) { _pos = startOffset; _length = endOffset; _scanMode = (ScanMode)state; _currentTokenType = null; }
private T4TokenNodeType ScanCore() { if (_pos >= _length) return null; // first test for a tag start or tag end, since they have precedence over everything in a T4 template if (_pos + 1 < _length) { switch (_buffer[_pos]) { // <#@, <#+, <#=, <# case '<': if ( _buffer[_pos + 1] == '#') { _pos += 2; if (_pos < _length) { switch (_buffer[_pos]) { case '@': ++_pos; _scanMode = ScanMode.Directive; return T4TokenNodeTypes.DirectiveStart; case '+': ++_pos; _scanMode = ScanMode.Code; return T4TokenNodeTypes.FeatureStart; case '=': ++_pos; _scanMode = ScanMode.Code; return T4TokenNodeTypes.ExpressionStart; } } _scanMode = ScanMode.Code; return T4TokenNodeTypes.StatementStart; } break; // #> case '#': if (_buffer[_pos + 1] == '>') { _pos += 2; _scanMode = ScanMode.Text; return T4TokenNodeTypes.BlockEnd; } break; } } // we have text, code or directive switch (_scanMode) { case ScanMode.Text: return ScanText(); case ScanMode.Code: return ScanCode(); case ScanMode.Directive: return ScanDirective(); case ScanMode.AttributeValue: return ScanAttributeValue(); default: throw new InvalidOperationException("Unknown state " + _scanMode); } }
void ScanDataSet(ScanMode mode) { Core.ScanInfoSet( ( int )nudStartXPos.Value, ( int )nudStartYPos.Value, ( int )nudEndXPos.Value, ( double )nudYstep.Value, -1, -1, ( int )nudScanbuffNum.Value, ( int )nudScanUnitNum.Value, ( int )nudScanLineNum.Value, ( int )nudScanSpeed.Value)(mode); }
private Edid(int id, int width, int height, float refreshRate, ScanMode scan = ScanMode.Progressive) { Id = id; Width = width; Height = height; RefreshRate = refreshRate; Scan = scan; }
public async Task <int> FindHostsAndAttack(ScanMode mode = ScanMode.Potator, bool active_protecte_cluster_ddos = false) { //string uhash = ""; //try //{ // var info = await this.MyInfo(); // uhash = (string)info["uhash"]; //} //catch (Exception e) //{ // config.logger.Log("Error: {0}", e.Message); //} //var stats = await CheckCluster(vhConsole.uHash); //var clusterBlocked = (string)stats["blocked"]; //if (clusterBlocked.Contains("Your Cluster is blocked") && active_protecte_cluster_ddos) //{ // config.logger.Log("Cluster blocked, skipping"); // TODO //} //else { var getImgBy = (GetImgBy)config.getImgBy; var temp = await GetImg(vhConsole.uHash, getImgBy); var data = (JArray)temp["data"]; foreach (var d in data) { try { var hostname = (string)d["hostname"]; // the purpose of this guy is to search for new ips: if this hostname // is one of the ones already stored we pass away, someone else will // hack him some time, sooner or later var found = config.persistanceMgr .GetIps() .FirstOrDefault(ip => ip.Hostname == hostname); if (found != null) { continue; // skips } //var imgString = "data: image/png;base64," + (string)d["img"]; var imgString = (string)d["img"]; var res = await ProcessImgAndAttack(imgString, hostname, mode); } catch (Exception e) { config.logger.Log(e.Message); } } } return(0); }
/// <summary> /// Launches a new process in the opposite mode (64/32 bit). /// </summary> /// <param name="mode">The mode.</param> /// <param name="fullPath">The full path.</param> /// <param name="bit64">if set to <see langword="true" /> [bit64].</param> private static void ExecuteAgain( ScanMode mode, [NotNull] string fullPath, bool bit64) { string executable = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\PerfSetup" + (bit64 ? "64" : "32") + ".exe"; if (!File.Exists(executable)) { Logger.Add( Level.Error, "Could not find '{0}' executable, could not add performance counters in {1} bit mode.", executable, bit64 ? 64 : 32); return; } try { if (fullPath.EndsWith(@"\")) { fullPath = fullPath.Substring(0, fullPath.Length - 1); } ProcessStartInfo processStartInfo = new ProcessStartInfo( executable, string.Format( "/E- {0} \"{1}\"", mode, fullPath)) { CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true }; Logger.Add(Level.Low, "Executing: {0} {1}", processStartInfo.FileName, processStartInfo.Arguments); Process process = Process.Start(processStartInfo); Debug.Assert(process != null); string output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); Logger.Add(Level.Low, output); Logger.Add(Level.High, "Completed execution in {0} mode.", bit64 ? 64 : 32); } catch (Exception e) { Logger.Add(Level.Error, "Failed execution in {0} mode. {1}", bit64 ? 64 : 32, e.Message); } }
internal void NotifyScanMode(ScanMode scan) { int ret = Interop.Bluetooth.NotifyScanMode((int)scan); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to notify scan mode to remote device, Error - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } }
internal void SetScanMode(ScanMode mode) { int ret = Interop.Bluetooth.SetScanMode(mode); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to set scan mode to " + mode + " - " + (BluetoothError)ret); BluetoothErrorFactory.ThrowBluetoothException(ret); } }
public async Task <int> attackIp2(string ip, string uhash, ScanMode mode) { var password = await vhUtils.JSONRequest("user::::pass::::uhash::::target", config.username + "::::" + config.password + "::::" + uhash + "::::" + ip, "vh_loadRemoteData.php"); //var password = await requestPassword(ip); var pwd = new PasswordImage((string)password["img"]); return(0); }
/// <summary> /// Notifies the scan mode to the remote device. /// </summary> /// <remarks> /// The remote device must be connected. /// </remarks> /// <param name="mode">The scan mode.</param> /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception> /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled /// or when notifying the scan mode state to the remote device fails.</exception> /// <since_tizen> 3 </since_tizen> public void NotifyScanMode(ScanMode mode) { if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { BluetoothAvrcpImpl.Instance.NotifyScanMode(mode); } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } }
// Instantiate the correct type of PortScanner private void InstantiatePortScanner(ScanMode scanMode) { switch (scanMode) { case ScanMode.TCP: portScanner = new TCPPortScanner(); break; case ScanMode.UDP: portScanner = new UDPPortScanner(); break; } }
public static void BluetoothScanMode(ScanMode scanMode) { if (!Application.isEditor) { #if UNITY_IOS || UNITY_TVOS #elif UNITY_ANDROID if (_android != null) { _android.Call("androidBluetoothScanMode", (int)scanMode); } #endif } }
/// <summary> /// Restores the lexer state. /// </summary> /// <param name="state">An instance of <see cref="State"/>.</param> private void RestoreState([CanBeNull] State state) { if (state == null) { return; } _pos = state.Pos; _tokenStart = state.TokenStart; _tokenEnd = state.TokenEnd; _scanMode = state.ScanMode; _currentTokenType = state.CurrentTokenType; }
/// <summary> /// Start lidar (at least try) /// </summary> /// <param name="mode">Scan mode</param> /// <returns>true if succeeded, false if not</returns> private bool StartLidar(ScanMode mode) { // Get health HealthInfo health = lidar.GetHealth(); if (health == null) { return(false); } // Good health ? if (health.Status != HealthStatus.Good) { logger.LogWarning($"Health {health.Status}, error code {health.ErrorCode}."); return(false); } // Good health logger.LogInformation($"Health good."); // Get configuration Configuration config = lidar.GetConfiguration(); if (config == null) { return(false); } // Show configuration logger.LogInformation("Configuration:"); foreach (KeyValuePair <ushort, ScanModeConfiguration> modeConfig in config.Modes) { logger.LogInformation($"0x{modeConfig.Key:X4} - {modeConfig.Value}" + (config.Typical == modeConfig.Key ? " (typical)" : string.Empty)); } // Start motor lidar.ControlMotorDtr(false); // Start scanning if (!lidar.StartScan(mode)) { return(false); } // Report logger.LogInformation("Scanning started."); return(true); }
/// <summary> /// Gets all types implementing a particular interface/base class /// </summary> /// <param name="type">Type to search for</param> /// <param name="mode">A <see cref="ScanMode"/> value to determin which type set to scan in.</param> /// <returns>An <see cref="IEnumerable{T}"/> of types.</returns> public static IEnumerable <Type> TypesOf(Type type, ScanMode mode) { var returnTypes = Types.Where(type.IsAssignableFrom); if (mode == ScanMode.All) { return(returnTypes); } return((mode == ScanMode.OnlyNancy) ? returnTypes.Where(t => t.Assembly == nancyAssembly) : returnTypes.Where(t => t.Assembly != nancyAssembly)); }
/// <summary> /// Set the Scan mode /// </summary> /// <param name="scanModeSelected">Sets the selected scan mode specified in the ScanMode enum</param> public void SetScanMode(ScanMode scanModeSelected) { OpenOptionsPanel(); if (!_controlPanel.ScrollPressWait("#hpid-option-scan-mode", "#hpid-option-scan-mode-screen", TimeSpan.FromSeconds(5))) { throw new DeviceWorkflowException("Unable to select scan mode option."); } _controlPanel.ScrollPress($"#hpid-scan-mode-selection-{scanModeSelected.ToString().ToLower()}"); Pacekeeper.Sync(); _controlPanel.PressWait(".hp-button-done", ".hp-option-list"); }
private async Task DoSeededEncounter(CancellationToken token) { ScanMode type = Hub.Config.SWSH_OverworldScan.EncounteringType; SAV8 sav = await GetFakeTrainerSAV(token).ConfigureAwait(false); Species dexn = 0; uint offset = 0x00; if (type == ScanMode.G_Articuno) { dexn = (Species)144; offset = CrownTundraSnowslideSlopeSpawns; } else if (type == ScanMode.G_Zapdos) { dexn = (Species)145; offset = WildAreaMotostokeSpawns; } else if (type == ScanMode.G_Moltres) { dexn = (Species)146; offset = IsleOfArmorStationSpaws; } else if (type == ScanMode.IoA_Wailord) { dexn = (Species)321; offset = IsleOfArmorStationSpaws; } while (!token.IsCancellationRequested && offset != 0) { var pkm = await ReadOwPokemon(dexn, offset, null, sav, token).ConfigureAwait(false); if (pkm != null && await HandleEncounter(pkm, IsPKLegendary(pkm.Species), token).ConfigureAwait(false)) { await Click(X, 2_000, token).ConfigureAwait(false); await Click(R, 2_000, token).ConfigureAwait(false); await Click(A, 5_000, token).ConfigureAwait(false); await Click(X, 2_000, token).ConfigureAwait(false); Log($"The overworld encounter has been found. The progresses has been saved and the game is paused, you can now go and catch {SpeciesName.GetSpeciesName((int)dexn, 2)}"); return; } else { await FlyToRerollSeed(token).ConfigureAwait(false); } } }
static public Edid GetEdid(int width, int height, float refreshRate, ScanMode scan = ScanMode.Progressive) { try { return(_edid.Single(s => ( s.Width == width && s.Height == height && s.RefreshRate == refreshRate && s.Scan == scan))); } catch (InvalidOperationException) { return(null); } }
private T4TokenNodeType ScanDirective() { char c = _buffer[_pos]; if (c == '"') { ++_pos; _scanMode = ScanMode.AttributeValue; return(T4TokenNodeTypes.Quote); } if (c == '=') { ++_pos; return(T4TokenNodeTypes.Equal); } if (c == '\r') { ++_pos; if (_pos < _length && _buffer[_pos] == '\n') { ++_pos; } return(T4TokenNodeTypes.NewLine); } if (c == '\n') { ++_pos; return(T4TokenNodeTypes.NewLine); } bool isWhiteSpace = Char.IsWhiteSpace(c); ++_pos; while (_pos < _length) { c = _buffer[_pos]; if (IsCurrentCharTag() || c == '"' || c == '=' || c == '\r' || c == '\n' || Char.IsWhiteSpace(c) != isWhiteSpace) { break; } ++_pos; } return(isWhiteSpace ? T4TokenNodeTypes.Space : T4TokenNodeTypes.Name); }
public Global() { ProTracReq = new byte[0] { }; CellScanReq = new byte[0] { }; UnSpeCellScanReq = new byte[0] { }; DebugReq = new byte[0] { }; testStatus = TestStatus.Stop; testMode = TestMode.RealTime; scanMode = ScanMode.Single; connectionStatus = false; }
public Config(ScanMode scanMode) { this.scanMode = scanMode; }
/// <summary> /// Launches a new process in the opposite mode (64/32 bit). /// </summary> /// <param name="mode">The mode.</param> /// <param name="fullPath">The full path.</param> /// <param name="bit64">if set to <see langword="true" /> [bit64].</param> private static void ExecuteAgain( ScanMode mode, [NotNull] string fullPath, bool bit64) { string executable = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\PerfSetup" + (bit64 ? "64" : "32") + ".exe"; if (!File.Exists(executable)) { Logger.Add( Level.Error, "Could not find '{0}' executable, could not add performance counters in {1} bit mode.", executable, bit64 ? 64 : 32); return; } try { if (fullPath.EndsWith(@"\")) fullPath = fullPath.Substring(0, fullPath.Length - 1); ProcessStartInfo processStartInfo = new ProcessStartInfo( executable, string.Format( "/E- {0} \"{1}\"", mode, fullPath)) { CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true }; Logger.Add(Level.Low, "Executing: {0} {1}", processStartInfo.FileName, processStartInfo.Arguments); Process process = Process.Start(processStartInfo); Debug.Assert(process != null); string output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); Logger.Add(Level.Low, output); Logger.Add(Level.High, "Completed execution in {0} mode.", bit64 ? 64 : 32); } catch (Exception e) { Logger.Add(Level.Error, "Failed execution in {0} mode. {1}", bit64 ? 64 : 32, e.Message); } }
/// <summary> /// Scans the supplied <see paramref="fullPath" /> (to a directory or assembly) for performance counters and adds/deletes/lists /// them depending on the <see paramref="mode" />. /// </summary> /// <param name="mode">The mode.</param> /// <param name="fullPath">The assemblies path.</param> /// <param name="executeAgain">if set to <see langword="true" /> execute's again on 64-bit OS.</param> public static void Execute( ScanMode mode, [NotNull] string fullPath, bool executeAgain) { if (fullPath == null) throw new ArgumentNullException("fullPath"); // Check we have access to the performance counters. PerformanceCounterCategory.Exists("TestAccess"); string[] files; string directory; try { fullPath = Path.GetFullPath(fullPath.Trim()); if (File.Exists(fullPath)) { directory = Path.GetDirectoryName(fullPath); files = new[] { fullPath }; } else if (Directory.Exists(fullPath)) { directory = fullPath; files = Directory.GetFiles(fullPath) .Where( f => { // ReSharper disable once PossibleNullReferenceException string ext = Path.GetExtension(f).ToLower(); return (ext == ".dll" || ext == ".exe"); }).ToArray(); } else { Logger.Add(Level.Error, "The '{0}' path is neither a file or directory.", fullPath); return; } } catch (Exception e) { Logger.Add(Level.Error, "The '{0}' path was invalid. {1}", fullPath, e.Message); return; } Debug.Assert(files != null); Debug.Assert(directory != null); if (!files.Any()) { Logger.Add( Level.Warning, "The '{0}' path did not match any executables or dlls, so no performance counters added.", fullPath); return; } AssemblyResolver.AddSearchDirectory(directory); foreach (string file in files) Load(file); int succeeded = 0; int failed = 0; foreach (PerfCategory performanceInformation in PerfCategory.All) switch (mode) { case ScanMode.Add: bool added = performanceInformation.Create(); Logger.Add( added ? Level.Normal : Level.Error, "Adding '{0}' {1}", performanceInformation, added ? "succeeded" : "failed"); if (added) succeeded++; else failed++; break; case ScanMode.Delete: bool deleted = performanceInformation.Delete(); Logger.Add( deleted ? Level.Normal : Level.Error, "Deleting '{0}' {1}", performanceInformation, deleted ? "succeeded" : "failed"); if (deleted) succeeded++; else failed++; break; default: // Treat everything else as list. bool exists = performanceInformation.Exists; Logger.Add( exists ? Level.Normal : Level.Error, "'{0}' {1}", performanceInformation, exists ? "exists" : "is missing"); if (exists) succeeded++; else failed++; break; } if (succeeded + failed > 0) { string operation; switch (mode) { case ScanMode.Add: operation = "Added"; break; case ScanMode.Delete: operation = "Deleted"; break; default: operation = "Found"; break; } Logger.Add( Level.High, "{0} '{1}' performance counters.{2}", operation, succeeded, failed > 0 ? string.Format(" {0} failures.", failed) : string.Empty); if (executeAgain && Environment.Is64BitOperatingSystem) { bool bit64 = Environment.Is64BitProcess; Logger.Add( Level.High, "Running PerfSetup in {0} bit process on 64 bit operating system, will run again in {1} bit mode to ensure counters are added to both environments!", bit64 ? 64 : 32, bit64 ? 32 : 64); ExecuteAgain(mode, fullPath, !bit64); } } else Logger.Add(Level.High, "No valid performance counters found."); }
/// <summary> /// Restores the lexer state. /// </summary> /// <param name="state">An instance of <see cref="State"/>.</param> private void RestoreState([CanBeNull] State state) { if (state == null) return; _pos = state.Pos; _tokenStart = state.TokenStart; _tokenEnd = state.TokenEnd; _scanMode = state.ScanMode; _currentTokenType = state.CurrentTokenType; }
public ScanResult[] ScanAll(Stream stream, ScanMode scanMode) { if (!stream.CanSeek) throw new IOException("Must be able to seek in the stream."); if (!stream.CanRead) throw new IOException("Must be able to read from the stream."); switch (scanMode) { case ScanMode.Hardcore: return ScanAllHardcore(stream); case ScanMode.Deep: return ScanAllDeep(stream); case ScanMode.Normal: default: return ScanAllNormal(stream); } }
private void MainForm_Load(object sender, EventArgs e) { InitFileFilters(); InitEnumDicts(); Text = BASE_TITLE; scan_mode = ScanMode.Normal; exe = null; }
/// <summary> /// Starts lexing a part of the buffer. /// </summary> /// <param name="startOffset">The starting offset.</param> /// <param name="endOffset">The ending offset.</param> /// <param name="state">The scan mode of the lexer.</param> public void Start(int startOffset, int endOffset, uint state) { _pos = startOffset; _length = endOffset; _scanMode = (ScanMode) state; _currentTokenType = null; }
public ScanResult Scan(Stream stream, ScanMode scanMode) { ScanResult[] results = ScanAll(stream,scanMode); if (results == null) return null; return results.LastOrDefault(); }
public Config Mode(ScanMode scanMode) { this.scanMode = scanMode; return this; }
private T4TokenNodeType ScanAttributeValue() { if (_buffer[_pos] == '"') { ++_pos; _scanMode = ScanMode.Directive; return T4TokenNodeTypes.Quote; } ++_pos; while (_pos < _length && !IsCurrentCharTag()) { switch (_buffer[_pos]) { case '"': return T4TokenNodeTypes.Value; case '\\': if (_pos + 1 < _length && _buffer[_pos + 1] == '"') ++_pos; break; } ++_pos; } return T4TokenNodeTypes.Value; }
private T4TokenNodeType ScanDirective() { char c = _buffer[_pos]; if (c == '"') { ++_pos; _scanMode = ScanMode.AttributeValue; return T4TokenNodeTypes.Quote; } if (c == '=') { ++_pos; return T4TokenNodeTypes.Equal; } if (c == '\r') { ++_pos; if (_pos < _length && _buffer[_pos] == '\n') ++_pos; return T4TokenNodeTypes.NewLine; } if (c == '\n') { ++_pos; return T4TokenNodeTypes.NewLine; } bool isWhiteSpace = Char.IsWhiteSpace(c); ++_pos; while (_pos < _length) { c = _buffer[_pos]; if (IsCurrentCharTag() || c == '"' || c == '=' || c == '\r' || c == '\n' || Char.IsWhiteSpace(c) != isWhiteSpace) break; ++_pos; } return isWhiteSpace ? T4TokenNodeTypes.Space : T4TokenNodeTypes.Name; }