コード例 #1
0
        private static void ServeRegistries(ILogger logger, string registries)
        {
            string                   contentRoot            = GetArgument("ContentRoot", $"Enter the path to the content root (default: {defaultContentRoot} ");
            DataSettings             dataSettings           = DataSettings.Current;
            IApplicationNameProvider appNameProvider        = DefaultConfigurationApplicationNameProvider.Instance;
            ServiceRegistryService   serviceRegistryService = ServiceRegistryService.GetLocalServiceRegistryService(dataSettings, appNameProvider, GetArgument("AssemblySearchPattern", "Please specify the AssemblySearchPattern to use"), logger);

            string[]        requestedRegistries = registries.DelimitSplit(",");
            HashSet <Type>  serviceTypes        = new HashSet <Type>();
            ServiceRegistry allTypes            = new ServiceRegistry();

            foreach (string registryName in requestedRegistries)
            {
                ServiceRegistry registry = serviceRegistryService.GetServiceRegistry(registryName);
                foreach (string className in registry.ClassNames)
                {
                    registry.Get(className, out Type type);
                    if (type.HasCustomAttributeOfType <ProxyAttribute>())
                    {
                        serviceTypes.Add(type);
                    }
                }
                allTypes.CombineWith(registry);
            }
            Type[] services = serviceTypes.ToArray();
            if (services.Length == 0)
            {
                throw new ArgumentException("No services were loaded");
            }
            ServeServiceTypes(contentRoot, ServiceConfig.GetConfiguredHostPrefixes(), allTypes, services);
            Pause($"Gloo server is serving services\r\n\t{services.ToArray().ToDelimited(s => s.FullName, "\r\n\t")}");
        }
コード例 #2
0
        public void CanRegisterContainer()
        {
            ServiceRegistryService svc = GetServiceRegistrationService(nameof(ServiceRegistryLoaderTest));
            List <ServiceRegistryContainerRegistrationResult> results = svc.RegisterServiceRegistryContainers(Assembly.GetExecutingAssembly());

            Expect.AreEqual(1, results.Count);
            CoreServices.ServiceRegistry registry = svc.GetServiceRegistry(results[0].Name);
            TestRegistryClass            instance = registry.Get <TestRegistryClass>();

            Expect.AreEqual(instance.SetByCtor, TestRegistryContainer.TestValue);
            Expect.AreEqual(typeof(ConsoleLogger), instance.Logger.GetType());
        }
コード例 #3
0
        public void ServiceRegistryLoaderTest()
        {
            ServiceRegistryService svc = GetServiceRegistrationService(nameof(ServiceRegistryLoaderTest));
            string name = nameof(ServiceRegistryLoaderTest);

            svc.RegisterServiceRegistryLoader(name, typeof(TestServiceRegistryContainer).GetMethod("Create"), true);

            CoreServices.ServiceRegistry reg = svc.GetServiceRegistry(name);
            TestMonkey value = reg.Get <TestMonkey>();

            Expect.AreEqual("SomeValue", value.Name);
            Expect.IsNull(value.Logger);
            reg.SetProperties(value);
            Expect.IsObjectOfType <ConsoleLogger>(value.Logger);
        }