Пример #1
0
        public CounterBusiness()
        {
            var cultureName = System.Configuration.ConfigurationManager.AppSettings["Culture"] as string;
            if (!string.IsNullOrEmpty(cultureName) && Thread.CurrentThread.CurrentCulture.Name != cultureName)
            {
                var previous = Thread.CurrentThread.CurrentCulture.Name;
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cultureName);
                OnChangedCurrentCultureEvent(new ChangedCurrentCultureEventArgs(previous, Thread.CurrentThread.CurrentCulture.Name));
            }

            _perfCounterProvider = new PerformanceCounterProvider(OnGetPerformanceCounters, null);
            _additionalProviders = new Dictionary<string, IPerformanceCounterProvider>(StringComparer.OrdinalIgnoreCase);
        }
Пример #2
0
        public CounterBusiness()
        {
            var cultureName = System.Configuration.ConfigurationManager.AppSettings["Culture"] as string;

            if (!string.IsNullOrEmpty(cultureName) && Thread.CurrentThread.CurrentCulture.Name != cultureName)
            {
                var previous = Thread.CurrentThread.CurrentCulture.Name;
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cultureName);
                OnChangedCurrentCultureEvent(new ChangedCurrentCultureEventArgs(previous, Thread.CurrentThread.CurrentCulture.Name));
            }

            _perfCounterProvider = new PerformanceCounterProvider(OnGetPerformanceCounters, null);
            _additionalProviders = new Dictionary <string, IPerformanceCounterProvider>(StringComparer.OrdinalIgnoreCase);
        }
Пример #3
0
        public void Apply_Replacement_Filter_With_Multiple_Names()
        {
            // arrange
            var counters = Mocks.Of<ICounter>(z => z.CategoryName == "Processor" && z.CounterName == "% Processor Time" && z.InstanceName == "*").Take(1).ToList();
            var counterGroup = Mocks.Of<ICounterGroup>(y => y.Name == "A" && y.SecondsInterval == 10 && y.Counters == counters).Take(1).ToList();
            var config = Mock.Of<IConfig>(x => x.Groups == counterGroup);
            var counterBusiness = new PerformanceCounterProvider(null, counter => new[]
            {
                new PerformanceCounterInfo(null, null, "w3wp", null, null, null, null),
                new PerformanceCounterInfo(null, null, "w3wp", null, null, null, null),
                new PerformanceCounterInfo(null, null, "w3wp", null, null, null, null),
                new PerformanceCounterInfo(null, null, "w3wp", null, null, null, null),
            });

            // act
            var result = new[] { counterBusiness.GetGroup(counterGroup.First()) };

            // assert
            Assert.That(result.Length, Is.EqualTo(1));
            var resultCounters = result.First().GetCounters().ToList();
            Assert.That(resultCounters.Count, Is.EqualTo(4));
            Assert.That(resultCounters.First().InstanceName, Is.EqualTo("w3wp"));
            Assert.That(resultCounters.ElementAt(1).InstanceName, Is.EqualTo("w3wp#2"));
            Assert.That(resultCounters.ElementAt(2).InstanceName, Is.EqualTo("w3wp#3"));
            Assert.That(resultCounters.ElementAt(3).InstanceName, Is.EqualTo("w3wp#4"));
        }