Project Description
C# extensions for the Ocean API.

The Ocean Petrel Extensions is a set of C#
extension methods to the Ocean Petrel API. The
aim is provide convenience, discoverability and
remove code duplication.


Support for LINQ is already quite good in the
Ocean Petrel API, since it uses IEnumerable
throughout the API. A few extensions is added
to enable LINQ on the project level:
    var q = from Borehole bore in PetrelProject.PrimaryProject
            where bore.LastModified.Time < DateTime.Now
            group bore by bore.Operator;


Ocean Petrel keeps a clean separation between
model and view code. Although this is a very
good principle, it is sometimes inconvenient
for your code. We are trying to remedy this,
so instead of:
    GeoReferencedImage image;
    IGeoReferencedImageService service = CoreSystem.GetService<IGeoReferencedImageService>(image);
    service.SetBitmap(image, myBitmap);

You can write:

Code that uses the Ocean Petrel API often ends
up repeating idiomatic expressions. We have tried
to capture these as extension methods, so
instead of:
    ITemplate template = PetrelUnitSystem.TemplateGroupSeismicColor.SeismicDefault;
    IPropertyVersionContainer container = PetrelUnitSystem.PropertyVersionService.GetGlobalPropertyVersionContainer()
    PropertyVersion version = PetrelUnitSystem.PropertyVersionService.FindOrCreate(container, template);

You can write:
    PropertyVersion version = PetrelUnitSystem.TemplateGroupSeismicColor.SeismicDefault.FindOrCreateGlobal();


A domain object in Ocean Petrel can have many
different roles. These are tied together with
services and factories. Some of these are very
well known, and we have provided shortcuts for
them. Instead of:
    IPresentationFactory factory = CoreSystem.GetService<IPresentationFactory>(domainObj);
    if (factory != null) {
        IPresentation presentation = factory.GetPresentation(domainObj);
        if (presentation != null) {
          dialog.Image = presentation.Image;

You can write:
    dialog.Image = domainObj.PetrelServices().Presentation.Image;


You sometimes need to annotate Petrel objects
with attributes. Ocean Petrel Extensions provides
convenience for this.

Create your annotation class:
    public class MyAttributes : CustomAttributesBase
        public string MyString
            get { return GetForProperty(this, a => a.MyString); }
            set { SetForProperty(this, a => a.MyString, value); }

An extension method:
    public static class ProspectExtensions
        public static MyAttributes Mine(this IIdentifiable owner)
            return CustomAttributes.AttributeFor<MyAttributes>(owner);

And you can get and set custom attributes like this:
    Borehole bore;
    bore.Mine().MyString = "Foo";

The attributes will be stored in the Petrel project and will
also be transfered with the Project Reference Tool. This is
a wrappers around the Slb.Ocean.Petrel.IO.ICustomAttributeService.


To use Ocean Petrel Extensions, add this to your code file:
    using Public.Ocean.Petrel.Extensions.Attributes;
    using Public.Ocean.Petrel.Extensions.DomainObject;
    using Public.Ocean.Petrel.Extensions.Services;

Now enjoy a lot of new methods in IntelliSense.

Note that the Ocean Petrel Extensions are not a product
supported by Schlumberger. See LICENSE.TXT.

Last edited Nov 9, 2009 at 9:05 AM by hgrim22, version 9