02.05.2014 Views

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Droid Class<br />

the Droid string can indicate a local server when the source is local. The Droid is created<br />

with a link to the class that implements IDataSource for its data.<br />

The Droid class is defined as:<br />

public class Droid<br />

{<br />

public Droid (string Droid);<br />

public Droid (string source, string id);<br />

public override bool Equals (object obj);<br />

public static string Escape (string input);<br />

public override int GetHashCode ();<br />

public override string ToString ();<br />

public static string Unescape (string input);<br />

public static Droid Empty { get; }<br />

public string Instance { get; }<br />

public bool IsEmpty { get; }<br />

public string Source { get; }<br />

}<br />

public static bool operator != (Droid left, Droid right);<br />

public static bool operator == (Droid left, Droid right);<br />

The Slb.<strong>Ocean</strong>.Data.Hosting.ObjectId class provides assistance with Droid<br />

creation. The objects type and identifier, perhaps from its row in a database table, can be<br />

used to create the ObjectId portion of the Droid. The IDataSource.Id property for<br />

the object is combined with this to form the Droid. The Droid class has two public<br />

constructors that will throw an exception for improperly formatted Droid strings.<br />

public MyDomainObj(IDataSource dataSource, string dataType, string id)<br />

{<br />

// Create an object id from the data type and id string<br />

ObjectId objId = new ObjectId(dataType, new String[] { "Id", id });<br />

// Use id from datasource and created object id to create a Droid<br />

Droid m_Droid = new Droid(dataSource.Id, objId.ToString());<br />

}<br />

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

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

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

Saved successfully!

Ooh no, something went wrong!