Exemple #1
0
        protected override void RegisterServices(ContainerBuilder builder)
        {
            var localWsEntryTypes = ServiceEntryHelper.FindServiceLocalWsEntryTypes(EngineContext.Current.TypeFinder)
                                    .ToArray();

            builder.RegisterTypes(localWsEntryTypes)
            .PropertiesAutowired()
            .AsSelf()
            .SingleInstance()
            .AsImplementedInterfaces();

            var serviceKeyTypes =
                localWsEntryTypes.Where(p => p.GetCustomAttributes().OfType <ServiceKeyAttribute>().Any());

            foreach (var serviceKeyType in serviceKeyTypes)
            {
                var serviceKeyAttribute = serviceKeyType.GetCustomAttributes().OfType <ServiceKeyAttribute>().First();
                builder.RegisterType(serviceKeyType).Named(serviceKeyAttribute.Name,
                                                           serviceKeyType.GetInterfaces().First(p =>
                                                                                                p.GetCustomAttributes().OfType <IRouteTemplateProvider>().Any()))
                .PropertiesAutowired()
                .AsSelf()
                .SingleInstance()
                .AsImplementedInterfaces();
            }
        }
        public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
        {
            var serviceEntryServiceTypes =
                ServiceEntryHelper.FindServiceEntryProxyTypes(EngineContext.Current.TypeFinder);

            foreach (var serviceEntryServiceType in serviceEntryServiceTypes)
            {
                AddAServiceEntryClientProxy(services, serviceEntryServiceType);
            }
        }
        public IReadOnlyList <ServiceEntry> GetEntries()
        {
            var serviceEntryTypes = ServiceEntryHelper.FindAllServiceEntryTypes(_typeFinder);

            Logger.LogDebug($"发现了以下服务:{string.Join(",", serviceEntryTypes.Select(i => i.ToString()))}。");
            var entries = new List <ServiceEntry>();

            foreach (var serviceEntryType in serviceEntryTypes)
            {
                entries.AddRange(_serviceEntryGenerator.CreateServiceEntry(serviceEntryType));
            }
            return(entries);
        }