private void RegisterClassesFromPathAndProjectThatUseIAppSettings(IWindsorContainer container) { foreach (var path in _paths) { try { container.Kernel.Register( Classes.FromAssemblyInDirectory(new AssemblyFilter(path) .FilterByName(an => _projects.Any(x => an.Name.ToLower().StartsWith(x, StringComparison.Ordinal)))) .Where(t => t.GetCustomAttributes(typeof(InverstionOfControlInstallAsAppSetting), true).Any()) .Configure( component => { component.Named($"{component.Implementation.FullName}-{AppSettingsModelpostfix}"); component.IsDefault(); }) .WithServiceDefaultInterfaces() .LifestyleSingleton()); } catch (Exception exception) { LoggingFactory.Create(GetType()).Error(exception, $"{GetType()} failed to install"); throw new MisconfiguredComponentException(exception); } } }
public void Install(IWindsorContainer container, IConfigurationStore store) { try { foreach (var path in _paths) { container.Register(Classes.FromAssemblyInDirectory( new AssemblyFilter(path). FilterByName(an => _projects.Any(x => an.Name.ToLower().StartsWith(x, StringComparison.Ordinal)))) .Where(t => t.GetCustomAttributes(typeof(InverstionOfControlInstallAsSingleton), true).Any()) .WithServiceAllInterfaces() .Configure(component => { component.IsDefault(); component.Named($"{component.Implementation.FullName}-Singleton"); }) .LifestyleSingleton()); } } catch (Exception exception) { LoggingFactory.Create(GetType()).Error(exception, $"{GetType()} failed to install"); throw new MisconfiguredComponentException(exception); } }
public void Install(IWindsorContainer container, IConfigurationStore store) { try { if (FacilityHelper.DoesKernelNotAlreadyContainFacility <TypedFactoryFacility>(container)) { container.Kernel.AddFacility <TypedFactoryFacility>(); } foreach (var path in _paths.Distinct()) { container.Register(Types.FromAssemblyInDirectory( new AssemblyFilter(path). FilterByName(an => _projects.Any(x => an.Name.ToLower().StartsWith(x, StringComparison.Ordinal)))) .Where(t => t.IsInterface && t.GetCustomAttributes(typeof(InverstionOfControlInstallAsFactory), true).Any()) .Configure(x => x.AsFactory()) .LifestyleSingleton()); } } catch (Exception exception) { LoggingFactory.Create(GetType()).Error(exception, $"{GetType()} failed to install"); throw new MisconfiguredComponentException(exception); } }
public void Install(IWindsorContainer container, IConfigurationStore store) { try { foreach (var path in _paths) { container.Register(Classes.FromAssemblyInDirectory( new AssemblyFilter(path) .FilterByName(an => _projects.Any(x => an.Name.ToLower().StartsWith(x, StringComparison.Ordinal)))) .IncludeNonPublicTypes() .Where(t => t.GetInterfaces().Any(x => x != typeof(IDisposable)) && !t.IsAssignableFrom(typeof(Exception)) && !t.GetCustomAttributes(false).Any(x => x.ToString().Contains("InverstionOfControl") || x is NoIoC)) .Configure(registration => { registration.IsFallback(); registration.Named($"{registration.Implementation.FullName}-TransientFallback"); }) .WithServiceAllInterfaces() .LifestyleTransient()); } } catch (Exception exception) { LoggingFactory.Create(GetType()).Error(exception, $"{GetType()} failed to install"); throw new MisconfiguredComponentException(exception); } }
public void ConsoleAndFile_Create_ReturnsMultipleProvidersCount() { var factory = new LoggingFactory(); using var logger = factory.Create(new[] { "Console", "File" }); logger.Providers.Count().ShouldBe(2); }
public void FileOnly_Create_ReturnsFileLogProvider(string loggerName) { var factory = new LoggingFactory(); using var logger = factory.Create(new[] { loggerName }); logger.Providers.First().ShouldBeOfType <FileLogProvider>(); }
public void EmptyProviderList_Create_ReturnsDefaultConsoleLogProvider() { var factory = new LoggingFactory(); using var logger = factory.Create(new string[0]); logger.Providers.First().ShouldBeOfType <ConsoleLogProvider>(); }
public void UnknownProvider_Create_ReturnsDefaultConsoleLogProvider() { var factory = new LoggingFactory(); using var logger = factory.Create(new [] { "Unknown" }); logger.Providers.First().ShouldBeOfType <ConsoleLogProvider>(); }
public void UnknownProvider_Create_ReturnsSingleProviderCount() { var factory = new LoggingFactory(); using var logger = factory.Create(new [] { "Unknown" }); logger.Providers.Count().ShouldBe(1); }
private void Setup(IWindsorContainer container, ILogger logger) { if (_logger == null) { _logger = logger ?? LoggingFactory.Create(GetType()); } container.Register(Component.For <IWindsorNancyBootstrapperWrapper>() .UsingFactoryMethod(() => new WindsorNancyBootstrapperWrapper(container)).IsDefault()); }
public void FileAndConsole_Create_ReturnsMultipleProviders() { var factory = new LoggingFactory(); using var logger = factory.Create(new[] { "File", "Console" }); logger.Providers.First().ShouldBeOfType <FileLogProvider>(); logger.Providers.Last().ShouldBeOfType <ConsoleLogProvider>(); }
public void Install(IWindsorContainer container, IConfigurationStore store) { try { container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel, true)); container.Kernel.Resolver.AddSubResolver(new ListResolver(container.Kernel, true)); container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel, true)); } catch (Exception exception) { LoggingFactory.Create(GetType()).Error(exception, $"{GetType()} failed to install"); throw new MisconfiguredComponentException(exception); } }
protected ILogger CreateInversionOfControlContainer() { try { _generalNLogFactory.AddNLogFactory(Container); Container.Install(FromAssembly.This()); var logger = Container.Resolve <ILogger>(new { type = GetType() }); return(logger); } catch (Exception exception) { LoggingFactory.Create(GetType()).Fatal(exception, "Initialization failed"); Trace.WriteLine(exception); } return(null); }
public void Install(IWindsorContainer container, IConfigurationStore store) { var logger = LoggingFactory.Create(GetType()); try { if (FacilityHelper.DoesKernelNotAlreadyContainFacility <TypedFactoryFacility>(container)) { container.Kernel.AddFacility <TypedFactoryFacility>(); } if (FacilityHelper.DoesKernelNotAlreadyContainFacility <WcfFacility>(container)) { container.Kernel.AddFacility <WcfFacility>(); } var returnFaults = new ServiceDebugBehavior { IncludeExceptionDetailInFaults = true, HttpHelpPageEnabled = true, }; container.Register(Component.For <IServiceBehavior>().Instance(returnFaults).IsFallback()); var assemblies = new List <Assembly>(); foreach (var path in _paths) { foreach (var sufix in ProjectMetadata.ProjectPrefixName) { if (!Directory.Exists(path)) { continue; } var files = Directory.GetFiles(path, $"{sufix}*.dll"); assemblies.AddRange(files.Select(Assembly.LoadFile)); } } var types = assemblies.SelectMany(s => s.GetTypes()).OrderBy(x => x.Name).ToArray(); RegisterBasicHttpBinding(container, types, logger); } catch (Exception exception) { logger.Error(exception, $"{GetType()} failed to install"); throw; } }
private static ILogger CreateLogger(string[] loggers) { var loggingFactory = new LoggingFactory(); return(loggingFactory.Create(loggers)); }
public CodeCampControl() { _logger = LoggingFactory.Create(GetType()); }