示例#1
0
        public void Scanner_should_find_all_handlers_types()
        {
            var handlerTypes = scanner.FindTypes(typeof(IHandle <>));

            Assert.Contains(typeof(BarHandler), handlerTypes);
            Assert.Contains(typeof(FooHandler), handlerTypes);
        }
示例#2
0
        private void RegisterMiddlewares()
        {
            var assemblyScanner = new AssemblyScanner();
            var types           = assemblyScanner.FindTypes <IMiddleware>();

            foreach (var type in types)
            {
                if (type.IsInterface())
                {
                    continue;
                }
                if (type.ImplementsInterface(typeof(IPreMiddleware)))
                {
                    Register(typeof(IPreMiddleware), type, type.FullName);
                    continue;
                }
                if (type.ImplementsInterface(typeof(ISystemMiddleware)))
                {
                    Register(typeof(ISystemMiddleware), type, type.FullName);
                    continue;
                }

                Register(typeof(IMiddleware), type, type.FullName);
            }
        }
示例#3
0
 private static void ResolveTypes()
 {
     var scanner = new AssemblyScanner();
     var foundType = scanner.FindTypes<IStartupTask>();
     startupTaskTypes.Clear();
     startupTaskTypes.AddRange(foundType);
 }
示例#4
0
        public void Prime()
        {
            var scanner = new AssemblyScanner();
            var handlerTypes = scanner.FindTypes(typeof(IHandle<>));

            foreach (var handlerType in handlerTypes)
            {
                Add(handlerType);
            }
        }
示例#5
0
        private static Type ResolveType(Type type)
        {
            var types        = assemblyScanner.FindTypes(type);
            var resolvedType = types.All(x => x.IsLocal()) ? types.LastOrDefault() : types.LastOrDefault(x => !x.IsLocal());

            if (resolvedType != null)
            {
                return(resolvedType);
            }

            throw new Exception($"Unable to resolve type: {type}");
        }
示例#6
0
        public void Prime()
        {
            var scanner      = new AssemblyScanner();
            var handlerTypes = scanner.FindTypes(typeof(IHandle <>));

            Clear();

            foreach (var handlerType in handlerTypes)
            {
                log.Debug($"Found handler {handlerType.Name}");
                Add(handlerType);
            }
        }
示例#7
0
        private void RegisterMessageHandlers()
        {
            var assemblyScanner = new AssemblyScanner();
            var types           = assemblyScanner.FindTypes <IMessageHandler>();

            foreach (var type in types)
            {
                if (type.IsInterface())
                {
                    continue;
                }
                Register(type, type, type.FullName);
            }
        }
示例#8
0
        private void RegisterShutdownTasks()
        {
            var assemblyScanner = new AssemblyScanner();
            var types           = assemblyScanner.FindTypes <IShutdownTask>();

            foreach (var type in types)
            {
                if (type.IsInterface())
                {
                    continue;
                }
                Register(typeof(IShutdownTask), type, type.FullName).As.Singleton();
            }
        }
示例#9
-1
 private static void ResolveTypes()
 {
     var scanner = new AssemblyScanner();
     var foundType = scanner.FindTypes<IMessageFilter>();
     filterTypes.Clear();
     filterTypes.AddRange(foundType);
 }