private async Task Load(object parm) { await RunCommand(() => this.LoginIsRuning, async() => { IoCConteiner.Get <ApplicationViewModel>().ServicesListVisible = false; await Task.Delay(1000); var metadataLoader = new MetadataLoader(new MetadataSetCreator(HostAddress)); ServiceProxyGenerator proxyGenerator = new ServiceProxyGenerator(metadataLoader); IoCConteiner.Get <ApplicationViewModel>().Services = proxyGenerator.CreateGenerator(); IoCConteiner.Get <ApplicationViewModel>().HostAddressControlVisible = false; IoCConteiner.Get <ApplicationViewModel>().ServicesListVisible = true; }); }
private TServiceInterface CreateServiceProxy <TServiceInterface>(Uri serviceUri, ServicePartitionKey partitionKey, TargetReplicaSelector targetReplicaSelector, string listenerName, Type serviceInterfaceType, ServiceProxyGenerator proxyGenerator) { var clientFactory = this.GetOrCreateServiceRemotingClientFactory(serviceInterfaceType); var serviceRemotingPartitionClient = new ServiceRemotingPartitionClient( clientFactory, serviceUri, partitionKey, targetReplicaSelector, listenerName, this.retrySettings); return((TServiceInterface)(object)proxyGenerator.CreateServiceProxy(serviceRemotingPartitionClient, clientFactory.GetRemotingMessageBodyFactory() )); }
static void Main(string[] args) { var localXmlFileLocalActorPath = Environment.CurrentDirectory + @"\\XmlConfiguration\\LocalActor.xml"; var localXmlFileLocalActorConfiguration = LocalXmlFileActorConfiguration.Load(localXmlFileLocalActorPath); var localActor = new RpcActor(localXmlFileLocalActorConfiguration); var localXmlFileActorRegistryPath = Environment.CurrentDirectory + @"\\XmlConfiguration\\ActorRegistry.xml"; var localXmlFileActorRegistry = LocalXmlFileActorRegistry.Load(localXmlFileActorRegistryPath); var actorDirectory = new LocalXmlFileActorDirectory(localXmlFileActorRegistry); var localXmlFileServiceRegistryPath = Environment.CurrentDirectory + @"\\XmlConfiguration\\ServiceRegistry.xml"; var serviceRegistry = LocalXmlFileServiceRegistry.Load(localXmlFileServiceRegistryPath); var serviceDiscovery = new LocalXmlFileServiceDiscovery(serviceRegistry); var serviceRetriever = new ServiceRetriever(serviceDiscovery); var serviceResolver = new ServiceResolver(serviceRetriever); var proxyGenerator = new ServiceProxyGenerator(serviceResolver); var rpcClient = new RpcClient(localActor, actorDirectory, proxyGenerator); var helloClient = rpcClient.Resolve <IHelloService>(); var calcClient = rpcClient.Resolve <ICalcService>(); rpcClient.Bootup(); var container = new TestContainer(); container.AddModule(new TestModule(helloClient, calcClient)); var bootstrapper = new Bootstrapper(); var engine = bootstrapper.BootWith(container); string uri = "http://localhost:3202/"; var host = new SelfHost(engine, new Uri(uri)); host.Start(); Console.WriteLine("Server is listening on [{0}].", uri); Console.WriteLine("Type something to stop ..."); Console.ReadKey(); host.Stop(); rpcClient.Shutdown(); Console.WriteLine("Stopped. Goodbye!"); }
OperationContext CreateOperationContext(Message incoming) { ServiceRuntimeChannel contextChannel; if (dispatch_runtime.HasCallbackRuntime) { var type = ServiceProxyGenerator.CreateCallbackProxyType(dispatch_runtime.Type, dispatch_runtime.CallbackClientRuntime.CallbackClientType); contextChannel = (ServiceRuntimeChannel)Activator.CreateInstance(type, new object [] { reply_or_input, dispatch_runtime }); } else { contextChannel = new ServiceRuntimeChannel(reply_or_input, dispatch_runtime); } OperationContext opCtx = new OperationContext(contextChannel); opCtx.IncomingMessage = incoming; opCtx.EndpointDispatcher = dispatch_runtime.EndpointDispatcher; return(opCtx); }
OperationContext CreateOperationContext(Message incoming) { IContextChannel contextChannel; if (dispatch_runtime.CallbackClientRuntime.CallbackClientType != null) { #if DISABLE_REAL_PROXY var type = ServiceProxyGenerator.CreateCallbackProxyType(dispatch_runtime, dispatch_runtime.CallbackClientRuntime.CallbackClientType); contextChannel = (ServiceRuntimeChannel)Activator.CreateInstance(type, new object [] { reply_or_input, dispatch_runtime }); #else contextChannel = (IContextChannel) new ClientRealProxy(dispatch_runtime.CallbackClientRuntime.CallbackClientType, new DuplexServiceRuntimeChannel(reply_or_input, dispatch_runtime), true).GetTransparentProxy(); #endif } else { contextChannel = new ServiceRuntimeChannel(reply_or_input, dispatch_runtime); } contextChannel.Open(); // FIXME: timeout? OperationContext opCtx = new OperationContext(contextChannel); opCtx.IncomingMessage = incoming; opCtx.EndpointDispatcher = dispatch_runtime.EndpointDispatcher; return(opCtx); }
static void Main(string[] args) { var localXmlFileLocalActorPath = Environment.CurrentDirectory + @"\\XmlConfiguration\\LocalActor.xml"; var localXmlFileLocalActorConfiguration = LocalXmlFileActorConfiguration.Load(localXmlFileLocalActorPath); var localActor = new RpcActor(localXmlFileLocalActorConfiguration); var consul = new ConsulClient((c) => { c.Address = new Uri("http://*****:*****@"^notify(\d*)$").Success) { var match = Regex.Match(text, @"notify(\d*)$"); int totalCalls = 0; if (!int.TryParse(match.Groups[1].Value, out totalCalls)) { totalCalls = 1; } for (int i = 0; i < totalCalls; i++) { NotifyOrderDelivered(orderEventClient); } } else { _log.WarnFormat("Cannot parse the operation for input [{0}].", text); } } catch (Exception ex) { _log.Error(ex.Message, ex); } } rpcNode.Shutdown(); }
static void Main(string[] args) { var localXmlFileLocalActorPath = Environment.CurrentDirectory + @"\\XmlConfiguration\\LocalActor.xml"; var localXmlFileLocalActorConfiguration = LocalXmlFileActorConfiguration.Load(localXmlFileLocalActorPath); var localActor = new RpcActor(localXmlFileLocalActorConfiguration); var localXmlFileActorRegistryPath = Environment.CurrentDirectory + @"\\XmlConfiguration\\ActorRegistry.xml"; var localXmlFileActorRegistry = LocalXmlFileActorRegistry.Load(localXmlFileActorRegistryPath); var actorDirectory = new LocalXmlFileActorDirectory(localXmlFileActorRegistry); var localXmlFileServiceRegistryPath = Environment.CurrentDirectory + @"\\XmlConfiguration\\ServiceRegistry.xml"; var serviceRegistry = LocalXmlFileServiceRegistry.Load(localXmlFileServiceRegistryPath); var serviceDiscovery = new LocalXmlFileServiceDiscovery(serviceRegistry); var serviceRetriever = new ServiceRetriever(serviceDiscovery); var serviceResolver = new ServiceResolver(serviceRetriever); var proxyGenerator = new ServiceProxyGenerator(serviceResolver); var rpcClient = new RpcClient(localActor, actorDirectory, proxyGenerator); var helloClient = rpcClient.Resolve <IHelloService>(); var calcClient = rpcClient.Resolve <ICalcService>(); var orderClient = rpcClient.Resolve <IOrderService>(); rpcClient.Bootup(); while (true) { try { string text = Console.ReadLine().ToLowerInvariant().Trim(); if (text == "quit" || text == "exit") { break; } else if (text == "reconnect") { rpcClient.Shutdown(); rpcClient.Bootup(); } else if (Regex.Match(text, @"^hello(\d*)$").Success) { var match = Regex.Match(text, @"^hello(\d*)$"); int totalCalls = 0; if (!int.TryParse(match.Groups[1].Value, out totalCalls)) { totalCalls = 1; } for (int i = 0; i < totalCalls; i++) { Hello(helloClient); } } else if (Regex.Match(text, @"^add(\d*)$").Success) { var match = Regex.Match(text, @"^add(\d*)$"); int totalCalls = 0; if (!int.TryParse(match.Groups[1].Value, out totalCalls)) { totalCalls = 1; } for (int i = 0; i < totalCalls; i++) { Add(calcClient); } } else if (Regex.Match(text, @"^order(\d*)$").Success) { var match = Regex.Match(text, @"order(\d*)$"); int totalCalls = 0; if (!int.TryParse(match.Groups[1].Value, out totalCalls)) { totalCalls = 1; } for (int i = 0; i < totalCalls; i++) { PlaceOrder(orderClient); } } else if (Regex.Match(text, @"^hello(\d+)x(\d+)$").Success) { var match = Regex.Match(text, @"^hello(\d+)x(\d+)$"); int totalCalls = int.Parse(match.Groups[1].Value); int threadCount = int.Parse(match.Groups[2].Value); Hello10000MultiThreading(helloClient, totalCalls, threadCount); } else if (Regex.Match(text, @"^add(\d+)x(\d+)$").Success) { var match = Regex.Match(text, @"^add(\d+)x(\d+)$"); int totalCalls = int.Parse(match.Groups[1].Value); int threadCount = int.Parse(match.Groups[2].Value); Add10000MultiThreading(calcClient, totalCalls, threadCount); } else { _log.WarnFormat("Cannot parse the operation for input [{0}].", text); } } catch (Exception ex) { _log.Error(ex.Message, ex); } } rpcClient.Shutdown(); }