02.05.2014 Views

Making custom domain objects RPT-enabled - Ocean - Schlumberger

Making custom domain objects RPT-enabled - Ocean - Schlumberger

Making custom domain objects RPT-enabled - 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.

{<br />

return new CustomDataSource(this.fileName, this.dataSourceID);<br />

}<br />

}<br />

2. Registering the factory in the Petrel project DataManager, on the Petrel Module initialization:<br />

public void Initialize()<br />

{<br />

CustomDSFactory dsf = new CustomDSFactory("CustomXYZ.dat", “My_DS_ID");<br />

PetrelSystem.AddDataSourceFactory(dsf);<br />

}<br />

Notice the CustomXYZ.dat file will contain the serialized <strong>custom</strong> <strong>objects</strong>:<br />

Figure 3: File containing the DataSource serialized<br />

3. Finally, the implementation of the <strong>custom</strong> data source that deals with<br />

serialization/deserialization and keeps a Hashtable to store the <strong>custom</strong> object and its Droid Id:<br />

public class CustomDataSource : IDataSource<br />

{<br />

public CustomDataSource(string fileName, string dataSourceIdentifier)<br />

{<br />

this.<strong>custom</strong>ObjectsDictionary = new Hashtable();<br />

(…)<br />

}<br />

// Adds an object and its droid to the dictionary<br />

public Droid Add(IIdentifiable <strong>custom</strong>Object)<br />

{<br />

Droid objectDroid = <strong>custom</strong>Object.Droid;<br />

if (objectDroid.Equals(Droid.Empty))<br />

objectDroid = new Droid(Id, Guid.NewGuid().ToString());<br />

this.<strong>custom</strong>ObjectsDictionary.Add(objectDroid, <strong>custom</strong>Object);<br />

return objectDroid;<br />

<strong>Ocean</strong> Developer Best Practices: <strong>Ocean</strong> for Petrel framework Page 4 of 9<br />

Submitted by the developer community<br />

*Mark of <strong>Schlumberger</strong>. Other company, product, and service names are the properties of their respective owners. Copyright © 2011<br />

<strong>Schlumberger</strong>. All rights reserved.

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

Saved successfully!

Ooh no, something went wrong!