Exemplo n.º 1
0
        private static ImmutableHashSet <IDiagnoser> GetDiagnosers(IEnumerable <IDiagnoser> diagnosers, ImmutableHashSet <HardwareCounter> uniqueHardwareCounters)
        {
            var builder = ImmutableHashSet.CreateBuilder(new TypeComparer <IDiagnoser>());

            foreach (var diagnoser in diagnosers)
            {
                if (!builder.Contains(diagnoser))
                {
                    builder.Add(diagnoser);
                }
            }

            if (!uniqueHardwareCounters.IsEmpty && !diagnosers.OfType <IHardwareCountersDiagnoser>().Any())
            {
                // if users define hardware counters via [HardwareCounters] we need to dynamically load the right diagnoser
                var hardwareCountersDiagnoser = DiagnosersLoader.GetImplementation <IHardwareCountersDiagnoser>();

                if (hardwareCountersDiagnoser != default(IDiagnoser) && !builder.Contains(hardwareCountersDiagnoser))
                {
                    builder.Add(hardwareCountersDiagnoser);
                }
            }

            return(builder.ToImmutable());
        }
Exemplo n.º 2
0
        public IEnumerable <IDiagnoser> GetDiagnosers()
        {
            if (hardwareCounters.IsEmpty())
            {
                return(diagnosers);
            }

            var hardwareCountersDiagnoser = DiagnosersLoader.GetImplementation <IHardwareCountersDiagnoser>();

            if (hardwareCountersDiagnoser != default(IDiagnoser))
            {
                return(diagnosers.Union(new [] { hardwareCountersDiagnoser }));
            }

            return(diagnosers);
        }