Seems I have to make my helper methods public if I want to use them within a code contract, but I avoid this by defining a property with the private setter to end up with the Contract.Requires<TException>(…) implementation below:
- public AbstractTrade Trade
- {
- private set { _trade = value; }
- get { return _trade; }
- }
- public void Execute()
- {
- Contract.Requires<TradingServiceException>(Trade.IsValid(),
- "Trade execution failed");
- if (TradeExecutedEvent != null)
- {
- TradeExecutedEvent(this, new TradeEventArgs(Trade));
- }
C:\Sandbox\Pricing\CommodityServer\TradingService\TradeManager.cs(24,13): error CC1038: Member 'Zainco.Commodities.TradingService.TradeManager.get_Trade' has less visibility than the enclosing method 'Zainco.Commodities.TradingService.TradeManager.Execute'.
C:\Sandbox\Pricing\CommodityServer\TradingService\TradeManager.cs(24,13): warning CC1036: Detected call to method 'Zainco.Commodities.Interfaces.AbstractTrade.IsValid' without [Pure] in contracts of method 'Zainco.Commodities.TradingService.TradeManager.Execute'.
elapsed time: 294.0169ms
No comments:
Post a Comment