コード例 #1
0
 public void Start(ServiceConfig serviceConfig)
 {
     IServiceAssembliesResolver assembliesResolver = GlobalSetting.Container.GetService<IServiceAssembliesResolver>();
     if (assembliesResolver == null)
         throw new NullReferenceException("IServiceAssembliesResolver接口不能为空");
     IServiceFinder serviceFinder = GlobalSetting.Container.GetService<IServiceFinder>();
     if (serviceFinder == null)
         throw new NullReferenceException("IServiceFinder接口不能为空");
     IEnumerable<ServiceMap> serviceMaps = FilterServiceMap(serviceFinder.Find(assembliesResolver.GetAssemblies()), serviceConfig.Server.Services);
     IServiceDiscoverer serviceDiscoverer = GlobalSetting.Container.GetService<IServiceDiscoverer>();
     if (serviceDiscoverer == null)
         throw new NullReferenceException("IServiceDiscoverer接口不能为空");
     serviceDiscoverer.RegistrationCenter = serviceConfig.RegistrationCenter;
     IEnumerable<Service> servics = FilterServices(serviceDiscoverer.Discover(serviceMaps), serviceConfig.Client.Services);
     IThriftClientActivator thriftClientActivator = GlobalSetting.Container.GetService<IThriftClientActivator>();
     if (thriftClientActivator == null)
         throw new NullReferenceException("IThriftClientActivator接口不能为空");
     thriftClientActivator.RegisterServices(servics);
 }
コード例 #2
0
        public static Type GetTypeFromAssemblies(string serviceInterfaceStr)
        {
            IServiceAssembliesResolver assembliesResolver = GlobalSetting.GetService <IServiceAssembliesResolver>();

            if (assembliesResolver == null)
            {
                throw new NullReferenceException("IServiceAssembliesResolver接口不能为空");
            }
            IEnumerable <Assembly> assemblies = assembliesResolver.GetAssemblies();

            foreach (Assembly assembly in assemblies.Where(tmp => tmp != null))
            {
                Type interfaceType = assembly.GetType(serviceInterfaceStr);
                if (interfaceType != null)
                {
                    return(interfaceType);
                }
            }

            return(null);
        }