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.

Data Management<br />

The events handlers for these events would be registered before the workspace is opened.<br />

For example:<br />

public void Initialize ()<br />

{<br />

DataManager.WorkspaceOpened += new System.EventHandler(WSOpened);<br />

DataManager.WorkspaceClosing += new<br />

System.ComponentModel.CancelEventHandler(WSClosing);<br />

DataManager.WorkspaceClosed += new System.EventHandler(WSClosed);<br />

...<br />

}<br />

The event handlers would then be something like:<br />

private void WSOpened(object sender, System.EventArgs e)<br />

{<br />

// Initialize our data source.<br />

string MyObjSource = “MyObjSource.xml”;<br />

IDataSource m_Source = DataManager.GetSource(MyObjSource);<br />

}<br />

private void WSClosing(object sender,<br />

System.ComponentModel.CancelEventArgs e)<br />

{<br />

// Save the data for our object<br />

m_Source.Save();<br />

}<br />

private void WSClosed(object sender, System.EventArgs e)<br />

{<br />

// Close the data source for our object<br />

m_Source.Close();<br />

}<br />

The WorkspaceClosing event is cancellable; an event handler that wishes to abort the<br />

closing of the workspace (perhaps due to inconsistencies in the workspace state managed<br />

by the module, required additional user input before close, or another situation in which it<br />

is not desirable to close down the workspace) may set the CancelEventArgs.Cancel<br />

property to true. Note that a product family does not have to honor the request to cancel;<br />

it is treated as a hint that may or may not be respected.<br />

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

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

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

Saved successfully!

Ooh no, something went wrong!