private static void Main(string[] args) { Console.WriteLine("请输入监听端口:"); var strPort = Console.ReadLine(); DependencyManage.UseAutofacContainer().UseNRpc().RegisterType <IStudentApplication, StudentApplication>().UseMongoDBMonitor(() => { return(new MonogoDbConfig("mongodb://*****:*****@192.168.100.125:27017", "Rpc_Monitor")); });; NRpcServer nrpcServer = new NRpcServer(int.Parse(strPort)); nrpcServer.RegisterServerType(typeof(IStudentApplication)); nrpcServer.Start(); Console.WriteLine("Welcome to use NetCoreRpc!"); Console.WriteLine("Input exit to exit"); var str = Console.ReadLine(); while (!string.Equals(str, "exit", StringComparison.OrdinalIgnoreCase)) { str = Console.ReadLine(); } nrpcServer.ShutDown(); }
private static void Main(string[] args) { Console.WriteLine("请输入监听端口:"); var strPort = Console.ReadLine(); var builder = new ConfigurationBuilder() .SetBasePath(Path.Combine(AppContext.BaseDirectory)).AddJsonFile("NetCoreRpc.json", optional: true); Configuration = builder.Build(); var servicesProvider = BuildDi(); DependencyManage.SetServiceProvider(servicesProvider, Configuration); NRpcServer nrpcServer = new NRpcServer(int.Parse(strPort)); nrpcServer.Start("NetCoreRpc.Application"); Console.WriteLine("Welcome to use NetCoreRpc!"); Console.WriteLine("Input exit to exit"); var str = Console.ReadLine(); while (!string.Equals(str, "exit", StringComparison.OrdinalIgnoreCase)) { str = Console.ReadLine(); } nrpcServer.ShutDown(); }