Ejemplo n.º 1
0
        internal void RegisterServices(IServiceCollection services)
        {
            services.AddSingleton(Type, Factory);
            services.AddSingleton(typeof(IEventListener), sp => sp.GetService(Type));

            // Register each events interface exposed at the level specified
            foreach (var i in EventParserTypes.GetEventInterfacesForCurrentRuntime(Type, Level))
            {
                services.AddSingleton(i, sp => sp.GetService(Type));
            }
        }
Ejemplo n.º 2
0
        public void When_Calling_GetEventParsers_Then_Returns_All_Event_Parsers_Defined_In_The_DotNetRuntime_Library()
        {
            var parsers = EventParserTypes.GetEventParsers();

            Assert.That(parsers, Is.SupersetOf(new[]
            {
                typeof(GcEventParser),
                typeof(JitEventParser),
                typeof(ThreadPoolEventParser),
                typeof(RuntimeEventParser),
                typeof(ContentionEventParser),
                typeof(ExceptionEventParser)
            }));
        }
Ejemplo n.º 3
0
        public void Given_A_Type_That_Implements_All_IEvent_Interfaces_When_Calling_GetLevelsFromType_Then_Returns_All_Interfaces_Except_IEvents()
        {
            var levels = EventParserTypes.GetLevelsFromParser(typeof(AllEvents));

            Assert.That(levels, Is.EquivalentTo(new[]
            {
                EventLevel.LogAlways,
                EventLevel.Verbose,
                EventLevel.Informational,
                EventLevel.Warning,
                EventLevel.Error,
                EventLevel.Critical
            }));
        }
        public static ListenerRegistration Create <T>(CaptureLevel level, Func <IServiceProvider, T> factory)
            where T : IEventListener
        {
            var supportedLevels = EventParserTypes.GetLevelsFromParser(typeof(T));
            var eventLevel      = level.ToEventLevel();

            if (!supportedLevels.Contains(eventLevel))
            {
                throw new UnsupportedEventParserLevelException(typeof(T), level, supportedLevels);
            }


            return(new ListenerRegistration(eventLevel, typeof(T), sp => (object)factory(sp)));
        }
Ejemplo n.º 5
0
        public void Given_A_Type_That_Implements_All_IEvent_Interfaces_When_Calling_GetEventInterfaces_Then_Returns_All_Interfaces_Except_IEvents()
        {
            var interfaces = EventParserTypes.GetEventInterfaces(typeof(AllEvents));

            Assert.That(interfaces, Is.EquivalentTo(new[]
            {
                typeof(AllEvents.Events.Verbose),
                typeof(AllEvents.Events.Info),
                typeof(AllEvents.Events.Warning),
                typeof(AllEvents.Events.Error),
                typeof(AllEvents.Events.Always),
                typeof(AllEvents.Events.Critical),
                typeof(AllEvents.Events.Counters)
            }));
        }
Ejemplo n.º 6
0
        public void When_Calling_GetEventInterfacesForCurrentRuntime_On_Net50_Then_Returns_Interfaces_For_Net50_Runtime_And_Below()
        {
            var interfaces = EventParserTypes.GetEventInterfacesForCurrentRuntime(typeof(VersionedEvents), EventLevel.LogAlways);

            Assert.That(interfaces, Is.EquivalentTo(new [] { typeof(VersionedEvents.Events.Counters), typeof(VersionedEvents.Events.CountersV3_1), typeof(VersionedEvents.Events.CountersV5_0) }));
        }
Ejemplo n.º 7
0
 public UnsupportedEventParserRuntimeException(Type type)
     : base($"{EventParserTypes.AreEventsSupportedByRuntime(type)}")
 {
     Type = type;
 }