11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

amrameshreddy.blog.com184 CHAPTER 6 ■ MANAGING WCF SERVICESramrameshreddy.blog.comThe ITradeMonitor interface is simple. You are implementing two methods:StartMonitoring and StopMonitoring. What is the objective of this interface? You are forcingthe classes that implement this interface to address monitoring activities that are “before” and“after” implementing the business logic. Therefore, alter TradeService.cs to implement thisinterface, as shown in Listing 6-2.■Note We are illustrating how to use custom-built interfaces as monitoring utilities in order to illustrateWCF managing and monitoring concepts. We have not implemented the best practices or any optimizationrequired to run this in production environments. This is an exercise to illustrate the “pain” developers willencounter when implementing management logic. We will walk through the WCF tools available that candeliver far more efficient and productive outcomes with only a configuration file switch.Listing 6-2. Altering the TradeService.cs Codeusing System;using System.ServiceModel;namespace ExchangeService{[ServiceContract(Namespace = "http://PracticalWcf/Exchange/TradeService",Name = "TradeService")]public interface ITradeService{[OperationContract]double TradeSecurity(string ticker, int quantity);}public class TradeService : ITradeService, ITradeMonitor{//Same code as Example 4, Chapter 4public string StartMonitoring(string ticker){lock (this){// Start the monitoring process here. In other words, you can// configure this function to start a manual log file// or send information to the event log. For this example, we are// returning a string to indicate the monitoring has commenced.return "Monitoring has started for " + ticker;}}ramrameshreddyramrameshreddy

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!