Exemplo n.º 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();
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        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));
            }
        }
Exemplo n.º 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")));
            });
        }
Exemplo n.º 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>";
Exemplo n.º 8
0
 public string Greeting(string name)
 {
     return(_helloService.Hello(name));
 }
Exemplo n.º 9
0
 public string Greeting()
 {
     return(_service.Hello());
 }
 public string Index(string name) => _helloService.Hello(name);
Exemplo n.º 11
0
 public void Run()
 {
     _hello.Hello();
 }
Exemplo n.º 12
0
 public string Greeting(string name) => $"<h2>{_helloService.Hello(name)}</h2>";
Exemplo n.º 13
0
 public string Greeting(string name)
 {
     //var service = new HelloService();
     //return service.Hello(name);
     return(_helloService.Hello(name));
 }
Exemplo n.º 14
0
 public string MyWebGreetings(string name) =>
 $"<h1>{_helloService.Hello(name)}</h1>";
 public string Index(string name)
 {
     return(_helloService.Hello(name));
 }