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.

CoreSystem Class<br />

The AddModules method returns a collection of exceptions that may have been thrown<br />

by the various methods called to get the added modules to the current state.<br />

// Define the module collection for addition<br />

ModuleReferenceCollection col = new ModuleReferenceCollection();<br />

// Define the module. format is Namespace.TypeName, AssemblyName<br />

string another<strong>Ocean</strong>Module =<br />

"<strong>Ocean</strong>Labs.Hello<strong>Ocean</strong>.Another<strong>Ocean</strong>Module, Hello<strong>Ocean</strong>Module";<br />

// Add the module to the collection.<br />

col.AddModule(another<strong>Ocean</strong>Module);<br />

// Create a ModuleTrust for the module<br />

ModuleTrust mt = new ModuleTrust(another<strong>Ocean</strong>Module);<br />

// Add the module to the system<br />

ReadOnlyCollection exs = CoreSystem.AddModules(col, mt);<br />

// Check the exceptions<br />

foreach (Exception e in exs)<br />

{<br />

// Process the exception. Print it, list it in the UI,<br />

// but do not throw it!<br />

CoreLogger.Error (“Error adding module: “ + another<strong>Ocean</strong>Module, e);<br />

}<br />

Services<br />

The CoreSystem Services property provides access to the <strong>Ocean</strong> Core<br />

ServiceLocator class. ServiceLocator is used to manage the services in the<br />

system. Services perform commonly used tasks and may register them against data types<br />

that use the tasks. The product family may load services provided by the <strong>Ocean</strong> Core such<br />

as the Units Service or the Coordinate System Service. Details on the ServiceLocator<br />

class are available in the section “ServiceLocator Class” on page 3-71.<br />

GetService Methods<br />

CoreSystem provides several overloads to the GetService method. GetService is a<br />

method in the ServiceLocator class used to find services added to the system by<br />

modules provided by the developer or the product family. The details of GetService are<br />

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

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

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

Saved successfully!

Ooh no, something went wrong!