public BatchStatsCalculator(ICalcService calcService, IEventBus eventBus) { Topic = EventTopic.BatchData; this.calcService = calcService; this.eventBus = eventBus; }
/// <summary> /// Associates this presenter with a calculation service object. /// </summary> /// <param name="service"> /// (Required.) Reference to an instance of an object that implements /// the <see cref="T:SampleMVP.ICalcService" /> interface. /// </param> /// <returns> /// Reference to the same instance of the object that called this /// method, for fluent use. /// </returns> /// <exception cref="T:System.ArgumentNullException"> /// Thrown if the required parameter, <paramref name="service" />, is /// passed a <c>null</c> value. /// </exception> public ICalcPresenter AndService(ICalcService service) { _service = service ?? throw new ArgumentNullException(nameof(service)); return(this); }
public AppController(IServiceProvider service) { _testService = service.GetRequiredService <ITestService>(); //testService; _logger = service.GetRequiredService <ILogger>(); //logger; _config = service.GetRequiredService <IOptions <ConfigSBS> >(); // config.Value; _calc = service.GetRequiredService <ICalcService>(); }
public void ClassInit() { var factory = new ChannelFactory <ICalcService>("tcpCalc"); ICalcService svc = factory.CreateChannel(); _svc = svc; }
private static void Add10000MultiThreading(ILog log, ICalcService calcClient, int totalCalls, int threadCount) { log.DebugFormat("Add10000MultiThreading, TotalCalls[{0}], ThreadCount[{1}], start ...", totalCalls, threadCount); var taskList = new Task[threadCount]; var watch = Stopwatch.StartNew(); for (int i = 0; i < threadCount; i++) { var task = Task.Factory.StartNew(() => { for (var j = 0; j < totalCalls / threadCount; j++) { calcClient.Add(new AddRequest() { X = 1, Y = 2 }); } }, TaskCreationOptions.PreferFairness); taskList[i] = task; } Task.WaitAll(taskList); watch.Stop(); log.DebugFormat("Add10000MultiThreading, TotalCalls[{0}], ThreadCount[{1}], end with cost [{2}] ms." + "{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}", totalCalls, threadCount, watch.ElapsedMilliseconds, Environment.NewLine, string.Format(" Concurrency level: {0} threads", threadCount), Environment.NewLine, string.Format(" Complete requests: {0}", totalCalls), Environment.NewLine, string.Format("Time taken for tests: {0} seconds", (decimal)watch.ElapsedMilliseconds / 1000m), Environment.NewLine, string.Format(" Time per request: {0:#####0.000} ms (avg)", (decimal)watch.ElapsedMilliseconds / (decimal)totalCalls), Environment.NewLine, string.Format(" Requests per second: {0} [#/sec] (avg)", (int)((decimal)totalCalls / ((decimal)watch.ElapsedMilliseconds / 1000m))) ); }
public LaunchPresenter(IKernel kernel, ILaunchView view, ICalcService service) { _kernel = kernel; _view = view; _service = service; _view.Launch += Launch; }
private static void TestCalcService() { // Öffnet die Http Verbindung und ruft CalcService.svc auf. Diese Route muss in Configure // der Datei Startup.cs registiert werden. BasicHttpBinding binding = new BasicHttpBinding(); EndpointAddress endpoint = new EndpointAddress($"{BaseUrl}/CalcService.asmx"); // Jetzt kommt das Interface ins Spiel. Der Request ruft Methoden von ICalcService // auf, deswegen verwenden wir hier das Interface. ChannelFactory <ICalcService> channelFactory = new ChannelFactory <ICalcService>(binding, endpoint); ICalcService serviceClient = channelFactory.CreateChannel(); // Nun können wir ganz normal Methoden aufrufen, wie wenn wir eine lokale // Klasse hätten, die das Interface implementiert. int result = serviceClient.Add(1, 3); List <CalcStats> calcCount = serviceClient.GetCalculationCount(); channelFactory.Close(); Console.WriteLine($"========================="); Console.WriteLine($"Das Ergebnis ist {result}"); foreach (var c in calcCount) { Console.WriteLine($"Operator {c.Operation}: {c.Count} Berechnungen durchgeführt."); } }
public CalcController(ICalcService calcService, ISessionService sessionService, IMapper mapper) { _calcService = calcService; _sessionService = sessionService; _mapper = mapper; }
private static void Add(ILog log, ICalcService calcClient) { var response = calcClient.Add(new AddRequest() { X = 3, Y = 4 }); log.DebugFormat("Add, receive add response from server with [{0}].", response.Result); }
public CalcPresenter(ICalcView view = null, ICalcModel model = null, ICalcService service = null) { _model = model; _service = service; _view = view; MapMessages(); }
public CalcPresenter(IKernel kernel, ICalcView view, ICalcService service) { _kernel = kernel; _view = view; _service = service; _view.Calculate += Calculate; _view.GetValues += GetValues; _view.GetInitialValues += GetInitialValues; }
public void CommonAppConsumingRemoteComponentsCallback() { ICalcService service = (ICalcService) Activator.GetObject(typeof(ICalcService), "tcp://localhost:2133/calcservice"); Assert.IsTrue(RemotingServices.IsTransparentProxy(service)); Assert.IsTrue(RemotingServices.IsObjectOutOfAppDomain(service)); Assert.AreEqual(10, service.Sum(7, 3)); }
private void Form1_Load(object sender, EventArgs e) { var endpoint = new EndpointAddress("http://localhost:5555/MathService"); channel = ChannelFactory <IMathServiceLibrary> .CreateChannel(new BasicHttpBinding(), endpoint); var endpoint2 = new EndpointAddress("http://localhost:8081/CalcService"); channel2 = ChannelFactory <ICalcService> .CreateChannel(new BasicHttpBinding(), endpoint2); }
public void InterfaceProxy() { _container.AddComponent("interceptor", typeof(ResultModifierInterceptor)); _container.AddComponent("key", typeof(ICalcService), typeof(CalculatorService)); ICalcService service = (ICalcService)_container.Resolve("key"); Assert.IsNotNull(service); Assert.AreEqual(7, service.Sum(2, 2)); }
public void MBRInterfaceProxy() { _container.AddComponent("interceptor", typeof(ResultModifierInterceptor)); _container.AddComponent("key", typeof(ICalcService), typeof(MarshalCalculatorService)); ICalcService service = (ICalcService)_container.Resolve("key"); Assert.IsNotNull(service); Assert.IsTrue(RemotingServices.IsTransparentProxy(service)); Assert.AreEqual(7, service.Sum(2, 2)); }
public void CommonAppConsumingRemoteComponentsCallback() { ICalcService service = (ICalcService) Activator.CreateInstance( typeof(CalcServiceImpl), null, new object[] { new UrlAttribute("tcp://localhost:2133/") }); Assert.IsTrue(RemotingServices.IsTransparentProxy(service)); Assert.IsTrue(RemotingServices.IsObjectOutOfAppDomain(service)); Assert.AreEqual(10, service.Sum(7, 3)); }
public void GetExistingServiceFromKernel() { WindsorContainer windsor = new WindsorContainer(); windsor.AddComponent("calculator", typeof(ICalcService), typeof(CalculatorService)); IContainerAdapter adapter = new ContainerAdapter(windsor); ICalcService service = (ICalcService)adapter.GetService(typeof(ICalcService)); Assert.IsNotNull(service); }
public void ClientContainerConsumingRemoteComponentCallback() { IWindsorContainer clientContainer = CreateRemoteContainer(clientDomain, "../Castle.Facilities.Remoting.Tests/client_simple_scenario.xml"); ICalcService service = (ICalcService)clientContainer[typeof(ICalcService)]; Assert.IsTrue(RemotingServices.IsTransparentProxy(service)); Assert.IsTrue(RemotingServices.IsObjectOutOfAppDomain(service)); Assert.AreEqual(10, service.Sum(7, 3)); }
public OrderController( IOrderManager orderManager, IProductManager productManager, IPromoCodeManager promoCodeManager, ICartService cartService, ICalcService calcService) { _orderManager = orderManager ?? throw new ArgumentNullException(nameof(orderManager)); _productManager = productManager ?? throw new ArgumentNullException(nameof(productManager)); _promoCodeManager = promoCodeManager ?? throw new ArgumentNullException(nameof(promoCodeManager)); _cartService = cartService ?? throw new ArgumentNullException(nameof(cartService)); _calcService = calcService ?? throw new ArgumentNullException(nameof(calcService)); }
public void AddServiceCreatorCallback() { ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateCalculatorService); container.AddService(typeof(ICalcService), callback); ICalcService service = (ICalcService)container.GetService(typeof(ICalcService)); Assert.IsNotNull(service); Assert.AreSame(service, container.Container[typeof(ICalcService)]); service = (ICalcService)container.GetService(typeof(ICalcService)); Assert.AreEqual(1, calledCount); }
public void ClientContainerConsumingRemoteComponentCallback() { IWindsorContainer clientContainer = CreateRemoteContainer(clientDomain, "../Castle.Facilities.Remoting.Tests/client_kernelcomponent.xml"); ICalcService service = (ICalcService)clientContainer[typeof(ICalcService)]; Assert.IsTrue(RemotingServices.IsTransparentProxy(service)); Assert.IsTrue(RemotingServices.IsObjectOutOfAppDomain(service)); // The result is being intercepted, that's why we // assert for 20 instead of 10 Assert.AreEqual(20, service.Sum(7, 3)); }
public static ICalcService Create(InsOptions options) { ICalcService insService = null; if (options.Region.RegionPart == RegionEnum.Central) { insService = new CalcServiceCentral(options); } else { // TODO: Реализовать северный и южный регион throw new NotImplementedException("Расчет выбранного региона пока не реализован."); } return(insService); }
public int Add(int a, int b) { using (ChannelFactory <ICalcService> factory = new ChannelFactory <ICalcService>("ep001")) { try { ICalcService client = factory.CreateChannel(); return(client.Add(a, b)); } catch (FaultException <FaultData> fault) { throw new Exception(fault.Message); } } }
// GET: Home public HomeController(IApplicationContext context, IEmailService emailService, ISearchService searchService, IShowAdvertService showAdvertService, ICounterService counterService, IOfferService offerService, ICalcService calcService, IGetNextPreviousService getNextPreviousService, INewestAdvertService newestAdvertService, IFilterIndexService filterIndexService, IGetFiltredAdvertsService getFiltredAdvertsService, IAdvertCitiesService advertCitiesService, IMaxPriceService maxPriceService) { _context = context; _emailService = emailService; _searchService = searchService; _showAdvertService = showAdvertService; _counterService = counterService; _offerService = offerService; _calcService = calcService; _getNextPreviousService = getNextPreviousService; _newestAdvertService = newestAdvertService; _filterIndexService = filterIndexService; _getFiltredAdvertsService = getFiltredAdvertsService; _advertCitiesService = advertCitiesService; _maxPriceService = maxPriceService; }
// GET: Admin public AdminController(IApplicationContext applicationContext, IAddAdvertService addAdvertService, IUpdateAdvertService updateAdvertService, IAdminLoginService adminLoginService, IEmailService emailService, IAdminFilterAdvertService adminFilterAdvertService, IOfferService offerService, IDeleteMessageService deleteMessageService, IGenericRepository genericRepository, ISearchService searchService, IChangeAdvertVisibility changeAdvertVisibility, ICalcService calcService, IAdminSettingsService adminSettingsService) { _applicationContext = applicationContext; _addAdvertService = addAdvertService; _updateAdvertService = updateAdvertService; _adminLoginService = adminLoginService; _emailService = emailService; _adminFilterAdvertService = adminFilterAdvertService; _offerService = offerService; _deleteMessageService = deleteMessageService; _genericRepository = genericRepository; _searchService = searchService; _changeAdvertVisibility = changeAdvertVisibility; _calcService = calcService; _adminSettingsService = adminSettingsService; }
public void InterfaceProxyWithLifecycle() { _container.AddComponent("interceptor", typeof(ResultModifierInterceptor)); _container.AddComponent("key", typeof(ICalcService), typeof(CalculatorServiceWithLifecycle)); ICalcService service = (ICalcService)_container.Resolve("key"); Assert.IsNotNull(service); Assert.IsTrue(RemotingServices.IsTransparentProxy(service)); Assert.IsTrue(service.Initialized); Assert.AreEqual(5, service.Sum(2, 2)); Assert.IsFalse(service.Disposed); _container.Release(service); }
static void Main(string[] args) { // Address string svcAddress = Host + ":" + Port + "/" + ServiceName; // Binding NetTcpBinding tcpb = new NetTcpBinding(SecurityMode.Message); ChannelFactory <ICalcService> chFactory = new ChannelFactory <ICalcService>(tcpb); // Endpoint EndpointAddress epAddress = new EndpointAddress(svcAddress); // Create Channel ICalcService calcService = chFactory.CreateChannel(epAddress); if (calcService == null) { throw new Exception("Failed to create channel for " + epAddress); } try { const int n1 = 4; const int n2 = 5; Console.WriteLine("Connected to service '" + svcAddress + "'."); var result = calcService.Add(n1, n2); Console.WriteLine("The result of " + n1 + "+" + n2 + " is '" + result + "'."); Console.WriteLine("Press key to quit."); Console.ReadKey( ); } finally { chFactory.Close( ); } }
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 void AddPromotedServiceCreatorCallback() { ContainerAdapter child = new ContainerAdapter(); container.Add(child); ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateCalculatorService); child.AddService(typeof(ICalcService), callback, true); ICalcService service = (ICalcService)child.GetService(typeof(ICalcService)); Assert.IsNotNull(service); ICalcService promotedService = (ICalcService)container.GetService(typeof(ICalcService)); Assert.IsNotNull(service); Assert.AreSame(service, promotedService); container.Remove(child); Assert.IsNull(child.GetService(typeof(ICalcService))); Assert.AreSame(container.GetService(typeof(ICalcService)), service); }
public CalcController(ICalcService calcService, IRNGService rngService) { this.calcService = calcService; this.rngService = rngService; }
public ConsumerComp(ICalcService calcservice) { this.calcservice = calcservice; }