示例#1
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder();
            IServiceCollection serviceDescriptors = new ServiceCollection();

            serviceDescriptors
            //.AddKestrelClient()
            .AddNetmqClient()
            .AddSingleton <IConfiguration>(i => builder.AddJsonFile("app.json").Build());

            IServiceProvider serviceProvider = serviceDescriptors.BuildServiceProvider();

            IHelloService helloService = serviceProvider.GetRequiredService <IHelloService>();


            Enumerable.Range(0, 10000).ToList().ForEach(async(item) =>
            {
                string data = await helloService.HelloAsync("1");
                Console.WriteLine(data);
                await Task.Factory.StartNew(() =>
                {
                    string result = helloService.Hello("2");
                    Console.WriteLine(result);
                });
            });

            Console.ReadKey();
        }
示例#2
0
        private static void Hello(ILog log, IHelloService helloClient)
        {
            var response = helloClient.Hello(new HelloRequest()
            {
                Text = DateTime.Now.ToString(@"yyyy-MM-dd HH:mm:ss.fffffff")
            });

            log.DebugFormat("Hello, receive hello response from server with [{0}].", response.Text);
        }
示例#3
0
文件: source.cs 项目: winxxp/samples
        public string Hello(string message)
        {
            WindowsIdentity callerWindowsIdentity = ServiceSecurityContext.Current.WindowsIdentity;

            if (callerWindowsIdentity == null)
            {
                throw new InvalidOperationException
                          ("The caller cannot be mapped to a Windows identity.");
            }
            using (callerWindowsIdentity.Impersonate())
            {
                EndpointAddress backendServiceAddress = new EndpointAddress("http://localhost:8000/ChannelApp");
                // Any binding that performs Windows authentication of the client can be used.
                ChannelFactory <IHelloService> channelFactory = new ChannelFactory <IHelloService>(new NetTcpBinding(), backendServiceAddress);
                IHelloService channel = channelFactory.CreateChannel();
                return(channel.Hello(message));
            }
        }
示例#4
0
        public TestModule(IHelloService helloService, ICalcService calcService)
        {
            _helloService = helloService;
            _calcService  = calcService;

            Get("/empty", x =>
            {
                return(string.Empty);
            });
            Get("/time", x =>
            {
                return(DateTime.Now.ToString(@"yyyy-MM-dd HH:mm:ss.fffffff"));
            });
            Get("/hello", x =>
            {
                var response = _helloService.Hello(new HelloRequest()
                {
                    Text = DateTime.Now.ToString(@"yyyy-MM-dd HH:mm:ss.fffffff")
                });
                return(response == null ? string.Empty : response.Text);
            });
            Get("/hello10000", x =>
            {
                var response = _helloService.Hello10000(new Hello10000Request()
                {
                    Text = DateTime.Now.ToString(@"yyyy-MM-dd HH:mm:ss.fffffff")
                });
                return(response == null ? string.Empty : response.Text);
            });
            Get("/add", x =>
            {
                var response = _calcService.Add(new AddRequest()
                {
                    X = 1, Y = 2
                });
                return(string.Format("Result = {0}, Time = {1}", response.Result.ToString(), DateTime.Now.ToString(@"yyyy-MM-dd HH:mm:ss.fffffff")));
            });
        }
示例#5
0
 public string Greeting(string name) => _helloService.Hello(name);
 protected override void DoProcessRequest(HttpContext context)
 {
     context.Response.Write(HelloService.Hello());
 }
 public string Index(string name) => $"<h1>{_helloService.Hello(name)}</h1>";
示例#8
0
 public string Greeting(string name)
 {
     return(_helloService.Hello(name));
 }
示例#9
0
 public string Greeting()
 {
     return(_service.Hello());
 }
 public string Index(string name) => _helloService.Hello(name);
示例#11
0
 public void Run()
 {
     _hello.Hello();
 }
示例#12
0
 public string Greeting(string name) => $"<h2>{_helloService.Hello(name)}</h2>";
示例#13
0
 public string Greeting(string name)
 {
     //var service = new HelloService();
     //return service.Hello(name);
     return(_helloService.Hello(name));
 }
 public string MyWebGreetings(string name) =>
 $"<h1>{_helloService.Hello(name)}</h1>";
 public string Index(string name)
 {
     return(_helloService.Hello(name));
 }