public void Send(DocumentChangeNotification documentChangeNotification) { var value = new { Value = documentChangeNotification, Type = "DocumentChangeNotification" }; if (watchAllDocuments > 0) { Enqueue(value); return; } if (documentChangeNotification.Id != null) { if (matchingDocuments.Contains(documentChangeNotification.Id)) { Enqueue(value); return; } var hasPrefix = matchingDocumentPrefixes.Any( x => documentChangeNotification.Id.StartsWith(x, StringComparison.InvariantCultureIgnoreCase)); if (hasPrefix == false) { return; } } Enqueue(value); }
private bool ShouldSend(Notification notification) { if (notification is FileChangeNotification && matchingFolders.Any( f => ((FileChangeNotification)notification).File.StartsWith(f, StringComparison.InvariantCultureIgnoreCase))) { return(true); } if (notification is ConfigurationChangeNotification && watchConfig > 0) { return(true); } if (notification is ConflictNotification && watchConflicts > 0) { return(true); } if (notification is SynchronizationUpdateNotification && watchSync > 0) { return(true); } return(false); }
public void Send(DocumentChangeNotification documentChangeNotification) { var value = new { Value = documentChangeNotification, Type = "DocumentChangeNotification" }; if (watchAllDocuments > 0) { Enqueue(value); return; } if (documentChangeNotification.Id != null && matchingDocuments.Contains(documentChangeNotification.Id)) { Enqueue(value); return; } var hasPrefix = documentChangeNotification.Id != null && matchingDocumentPrefixes .Any(x => documentChangeNotification.Id.StartsWith(x, StringComparison.InvariantCultureIgnoreCase)); if (hasPrefix) { Enqueue(value); return; } var hasCollection = documentChangeNotification.CollectionName != null && matchingDocumentsInCollection .Any(x => string.Equals(x, documentChangeNotification.CollectionName, StringComparison.InvariantCultureIgnoreCase)); if (hasCollection) { Enqueue(value); return; } var hasType = documentChangeNotification.TypeName != null && matchingDocumentsOfType .Any(x => string.Equals(x, documentChangeNotification.TypeName, StringComparison.InvariantCultureIgnoreCase)); if (hasType) { Enqueue(value); return; } if (documentChangeNotification.Id != null || documentChangeNotification.CollectionName != null || documentChangeNotification.TypeName != null) { return; } Enqueue(value); }
private bool TriggerNextServiceDiscoveryElseCompletion() { while (pendingServiceDiscoveryDevices.Any()) { var device = pendingServiceDiscoveryDevices.First(); pendingServiceDiscoveryDevices.RemoveOrThrow(device); Console.WriteLine($"Fetching UUIDs of device {device.Address} {device.Name ?? "[no name]"}"); var result = device.FetchUuidsWithSdp(); Console.WriteLine("Fetch returned " + result); return(true); } return(false); }
public void SendDocumentChanges(DocumentChangeNotification notification) { if (_watchAllDocuments > 0) { Send(notification); return; } if (notification.Key != null && _matchingDocuments.Contains(notification.Key)) { Send(notification); return; } var hasPrefix = notification.Key != null && _matchingDocumentPrefixes .Any(x => notification.Key.StartsWith(x, StringComparison.OrdinalIgnoreCase)); if (hasPrefix) { Send(notification); return; } var hasCollection = notification.CollectionName != null && _matchingDocumentsInCollection .Any(x => string.Equals(x, notification.CollectionName, StringComparison.OrdinalIgnoreCase)); if (hasCollection) { Send(notification); return; } var hasType = notification.TypeName != null && _matchingDocumentsOfType .Any(x => string.Equals(x, notification.TypeName, StringComparison.OrdinalIgnoreCase)); if (hasType) { Send(notification); return; } if (notification.Key == null && notification.CollectionName == null && notification.TypeName == null) { Send(notification); } }
private static async Task <IEnumerable <INamedTypeSymbol> > GetDependentTypesAsync( INamedTypeSymbol type, Solution solution, IImmutableSet <Project> projects, Func <INamedTypeSymbol, INamedTypeSymbol, bool> predicate, ConditionalWeakTable <Compilation, ConcurrentDictionary <SymbolKey, List <SymbolKey> > > cache, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var dependentProjects = await DependentProjectsFinder.GetDependentProjectsAsync(type, solution, projects, cancellationToken).ConfigureAwait(false); // If it's a type from source, then only other types from source could derive from // it. If it's a type from metadata then unfortunately anything could derive from // it. bool locationsInMetadata = type.Locations.Any(loc => loc.IsInMetadata); ConcurrentSet <ISymbol> results = new ConcurrentSet <ISymbol>(SymbolEquivalenceComparer.Instance); cancellationToken.ThrowIfCancellationRequested(); var projectTasks = new List <Task>(); foreach (var project in dependentProjects) { projectTasks.Add(Task.Run( async() => await GetDependentTypesInProjectAsync(type, project, solution, predicate, cache, locationsInMetadata, results, cancellationToken).ConfigureAwait(false), cancellationToken)); } await Task.WhenAll(projectTasks).ConfigureAwait(false); if (results.Any()) { return(results.OfType <INamedTypeSymbol>()); } else { return(SpecializedCollections.EmptyEnumerable <INamedTypeSymbol>()); } }
public void Send(ChangeNotification notification) { var counterPrefix = CounterUtils.GetFullCounterName(notification.GroupName, notification.CounterName); if (watchAllCounters > 0 || matchingChanges.Contains(counterPrefix)) { var value = new { Value = notification, Type = changeNotificationType }; enqueue(value); } if (matchingPrefixes.Any(prefix => counterPrefix.StartsWith(prefix))) { var value = new { Value = notification, Type = startingWithNotification }; enqueue(value); } if (matchingGroups.Contains(notification.GroupName)) { var value = new { Value = notification, Type = inGroupNotificationType }; enqueue(value); } }
public static DateTime GetStrRequestTime(CheckOutDto checkOut, ConcurrentSet <DenyDto> denys, ConcurrentSet <CheckOutDto> checkOuts) { if (!denys.Any()) { return(checkOut.TimeStamp); } else { var userDenialsForProduct = denys.Where(x => x.User == checkOut.User && x.Product == checkOut.Product); if (userDenialsForProduct.Any()) { var lastCheckOutBeforCurrForProd = checkOuts.Where(x => x.TimeStamp <= checkOut.TimeStamp && x.Product == checkOut.Product) .OrderBy(x => x.TimeStamp).LastOrDefault(); var firstDenialforUserAfterAbove = userDenialsForProduct.FirstOrDefault(x => x.TimeStamp >= lastCheckOutBeforCurrForProd.TimeStamp && x.TimeStamp <= checkOut.TimeStamp); if (firstDenialforUserAfterAbove.TimeStamp != default(DateTime)) { return(firstDenialforUserAfterAbove.TimeStamp); } } else { return(checkOut.TimeStamp); } } return(checkOut.TimeStamp); }
private void OnCompilationStart(CompilationStartAnalysisContext context) { Assert.True(context.Compilation.Options.ConcurrentBuild, "This analyzer is intended to be used only when concurrent build is enabled."); var pendingSymbols = new ConcurrentSet <INamedTypeSymbol>(); foreach (var type in context.Compilation.GlobalNamespace.GetTypeMembers()) { if (_symbolNames.Contains(type.Name)) { pendingSymbols.Add(type); } } context.RegisterSymbolAction(symbolContext => { if (!pendingSymbols.Remove((INamedTypeSymbol)symbolContext.Symbol)) { return; } var myToken = Interlocked.Increment(ref _token); if (myToken == 1) { // Wait for all symbol callbacks to execute. // This analyzer will deadlock if the driver doesn't attempt concurrent callbacks. while (pendingSymbols.Any()) { Thread.Sleep(10); } } // ok, now report diagnostic on the symbol. var diagnostic = Diagnostic.Create(Descriptor, symbolContext.Symbol.Locations[0], symbolContext.Symbol.Name); symbolContext.ReportDiagnostic(diagnostic); }, SymbolKind.NamedType); }
private static async Task<IEnumerable<INamedTypeSymbol>> GetDependentTypesAsync( INamedTypeSymbol type, Solution solution, IImmutableSet<Project> projects, Func<INamedTypeSymbol, INamedTypeSymbol, bool> predicate, ConditionalWeakTable<Compilation, ConcurrentDictionary<SymbolKey, List<SymbolKey>>> cache, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var dependentProjects = await DependentProjectsFinder.GetDependentProjectsAsync(type, solution, projects, cancellationToken).ConfigureAwait(false); // If it's a type from source, then only other types from source could derive from // it. If it's a type from metadata then unfortunately anything could derive from // it. bool locationsInMetadata = type.Locations.Any(loc => loc.IsInMetadata); ConcurrentSet<ISymbol> results = new ConcurrentSet<ISymbol>(SymbolEquivalenceComparer.Instance); cancellationToken.ThrowIfCancellationRequested(); var projectTasks = new List<Task>(); foreach (var project in dependentProjects) { projectTasks.Add(Task.Run( async () => await GetDependentTypesInProjectAsync(type, project, solution, predicate, cache, locationsInMetadata, results, cancellationToken).ConfigureAwait(false), cancellationToken)); } await Task.WhenAll(projectTasks).ConfigureAwait(false); if (results.Any()) { return results.OfType<INamedTypeSymbol>(); } else { return SpecializedCollections.EmptyEnumerable<INamedTypeSymbol>(); } }