11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

amrameshreddy.blog.com318 CHAPTER 10 ■ INTEGRATING WITH COM+ramrameshreddy.blog.comThe solution also contains a couple of batch files (reg.bat and unreg.bat) that handle theGAC installation and COM+ application configuration. These batch files use the GacUtil.exeutility and the RegSvcs.exe utility that handles GAC and COM+ registration. As listed in theSDK requirements, a .NET component that is also a serviced component (COM+) must beregistered in the GAC, which requires it to have a strong name.The implementation of OldHorse2 is a mirror image of the Visual Basic 6 COM example,except it uses attributes from the Enterprise Services namespaces. Additionally, the Guidattribute is applied to ensure you leverage a consistent CLSID and APPID instead of relying onthe framework to regenerate each time.For the OldHorse2 project, Listing 10-6 shows the PositionManagement class. The codeprovides the sample simple interface as the Visual Basic 6 version along with Transactionattributes and AutoComplete attributes for transaction management.Listing 10-6. OldHorse2 PositionManagement.csusing System;using System.EnterpriseServices;using System.Runtime.InteropServices;namespace OldHorse2{[Guid( "3B26F4CA-E839-4ab6-86D4-AADB0A8AADA5" )]public interface IPositionManagement{long UpdatePosition( string ticker, long quantity );long GetQuantity( string ticker );}[Guid( "08F01AD6-F3EB-4f41-A73A-270AA942881A" )][Transaction(TransactionOption.Required)]public class PositionManagement : ServicedComponent, IPositionManagement{public PositionManagement() {}#region IPositionManagement Members[AutoComplete]public long UpdatePosition( string ticker, long quantity ){IPosition pos = new Position();pos = pos.GetPosition( ticker );pos.Quantity += quantity;return pos.Quantity;}ramrameshreddyramrameshreddy

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

Saved successfully!

Ooh no, something went wrong!