private static IEnumerable <T> GetAddInServices <T>(ContainerBuilder builder)
        {
            var addInsDirectoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin", "add-ins");

            using (var serviceProvider = RuntimeServiceProvider.Create(addInsDirectoryPath))
            {
                return(serviceProvider.GetExportedValues <T>());
            }
        }
Esempio n. 2
0
        private static void RegisterAuditingServices(ContainerBuilder builder, IAuditingService defaultAuditingService)
        {
            var addInsDirectoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin", "add-ins");

            using (var serviceProvider = RuntimeServiceProvider.Create(addInsDirectoryPath))
            {
                var auditingServices = serviceProvider.GetExportedValues <IAuditingService>();
                var services         = new List <IAuditingService>(auditingServices);

                if (defaultAuditingService != null)
                {
                    services.Add(defaultAuditingService);
                }

                var service = CombineServices(services);

                builder.RegisterInstance(service)
                .AsSelf()
                .As <IAuditingService>()
                .SingleInstance();
            }
        }