02.05.2014 Views

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

SHOW MORE
SHOW LESS

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

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

ServiceLocator Class<br />

RemoveService methods. There is a ServicesChanged event that is raised when a<br />

service is added or removed.<br />

public void Initialize ()<br />

{<br />

...<br />

// Add XYZ object service with renderer for map window<br />

CoreSystem.Services.AddService(typeof(XYZObject),<br />

typeof(IMapRenderer),<br />

new XYZMapView());<br />

}<br />

// Add XYZ object service wth renderer for 3D window<br />

CoreSystem.Services.AddService(typeof(XYZObject),<br />

typeof(IOpenInventorFactory),<br />

new XYZOIView());<br />

...<br />

CoreSystem provides CoreSystem.GetService as a shorthand implementation of<br />

CoreSystem.Services.GetService since this is the most used method of the<br />

Services property. It is overloaded with the same definitions as<br />

CoreSystem.Services.GetService. See the following example.<br />

public void Invoke()<br />

{<br />

...<br />

// Get XYZ object service (use longhand form)<br />

XYZObject xyzObj = CoreSystem.Services.GetService(typeof(XYZObject))<br />

as XYZObject;<br />

// Get Unit service (use shorthand form)<br />

IUnitService us = CoreSystem.GetService(typeof(IUnitService))<br />

as IUnitService;<br />

// Get Coordinate service (use even shorter form)<br />

CoordinateService us = CoreSystem.GetService();<br />

...<br />

}<br />

<strong>Schlumberger</strong> Private<br />

<strong>Ocean</strong> Core 3-73

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

Saved successfully!

Ooh no, something went wrong!