Esempio n. 1
0
        private static Task <bool> StartSever(IBuildEngine buildEngine)
        {
            var router = new DefaultTargetSelector();

            var host   = new MSBuildHostService(buildEngine);
            var result = host.ServerTask;

            router.Register <IMsBuildHostService, MSBuildHostService>(host);

            var tcpHost = new TcpHost(new Engine().CreateRequestHandler(router));

            result.ContinueWith(_ => { tcpHost.StopListening(); });

            tcpHost.StartListening(new System.Net.IPEndPoint(IPAddress.Loopback, 9000));

            Console.WriteLine("AvalonStudio MSBuild Host Started:");

            return(result);
        }
Esempio n. 2
0
        public static IApplicationBuilder UseCoreRpc(this IApplicationBuilder builder, PathString path,
                                                     Action <CoreRpcAspNetCoreConfiguration> configure = null)
        {
            var env = builder.ApplicationServices.GetRequiredService <IHostingEnvironment>();
            var cfg = new CoreRpcAspNetCoreConfiguration()
            {
                RpcTypeResolver = () => RpcTypesResolver.GetRpcTypes(env)
            };

            configure?.Invoke(cfg);
            var engine = new Engine(new JsonMethodCallSerializer(cfg.JsonSerializer), new DefaultMethodBinder());

            var types     = cfg.RpcTypeResolver();
            var extractor = new AspNetCoreTargetNameExtractor();
            var selector  = new DefaultTargetSelector(new AspNetCoreTargetFactory(), extractor);

            foreach (var t in types)
            {
                selector.Register(extractor.GetTargetName(t), t);
            }
            return(builder.UseCoreRpc(path, engine.CreateRequestHandler(selector, new CallInterceptor(cfg.Interceptors))));
        }