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);
            }
        }
예제 #2
0
        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;
            }
        }