Esempio n. 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")}");
        }
Esempio n. 2
0
        public void Serve()
        {
            try
            {
                string serviceClassName = GetArgument("serve", "Enter the name of the class to serve ");
                string contentRoot      = GetArgument("ContentRoot", $"Enter the path to the content root (default: {defaultContentRoot} ");
                Type   serviceType      = GetServiceType(serviceClassName, out Assembly assembly);
                if (serviceType == null)
                {
                    throw new InvalidOperationException(string.Format("The type {0} was not found in the assembly {1}", serviceClassName, assembly.GetFilePath()));
                }
                HostPrefix[] prefixes = ServiceConfig.GetConfiguredHostPrefixes();
                if (serviceType.HasCustomAttributeOfType(out ServiceSubdomainAttribute attr))
                {
                    foreach (HostPrefix prefix in prefixes)
                    {
                        prefix.HostName = $"{attr.Subdomain}.{prefix.HostName}";
                    }
                }

                ServeServiceTypes(contentRoot, prefixes, null, serviceType);
                Pause($"Gloo server is serving service {serviceClassName}");
            }
            catch (Exception ex)
            {
                Args.PopMessageAndStackTrace(ex, out StringBuilder message, out StringBuilder stackTrace);
                OutLineFormat("An error occurred: {0}", ConsoleColor.Red, message.ToString());
                OutLineFormat("{0}", stackTrace.ToString());
                Thread.Sleep(1500);
            }
        }
Esempio n. 3
0
        public void ServeCsGloo()
        {
            string   csglooDirectoryPath = GetArgument("CsGlooSrc", $"Enter the path to the CsGloo source directory (default: {defaultGlooScriptsSrcPath})");
            Assembly csglooAssembly      = CompileTvgSource(csglooDirectoryPath, "csgloo");

            string contentRoot = GetArgument("ContentRoot", $"Enter the path to the content root (default: {defaultContentRoot} ");

            HostPrefix[] prefixes  = ServiceConfig.GetConfiguredHostPrefixes();
            Type[]       glooTypes = csglooAssembly.GetTypes().Where(t => t.HasCustomAttributeOfType <ProxyAttribute>()).ToArray();
            ServeServiceTypes(contentRoot, prefixes, null, glooTypes);
            Pause($"Gloo server is serving cs gloo types: {string.Join(", ", glooTypes.Select(t => t.Name).ToArray())}");
        }
Esempio n. 4
0
 private static HostPrefix[] GetConfiguredHostPrefixes()
 {
     return(ServiceConfig.GetConfiguredHostPrefixes());
 }