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(); }
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); }
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)); } }
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"))); }); }
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>";
public string Greeting(string name) { return(_helloService.Hello(name)); }
public string Greeting() { return(_service.Hello()); }
public string Index(string name) => _helloService.Hello(name);
public void Run() { _hello.Hello(); }
public string Greeting(string name) => $"<h2>{_helloService.Hello(name)}</h2>";
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)); }