Transhipment: A WinRT library for sharing formatted data

September 16, 2012
Windows 8 WinRT

Windows 8 provides a standard mechanism for sharing data between apps – Share Contract. It works like a charm for the well-known formats like HTML or Url, but there are some issues with custom structured data sharing. I have mentioned the formats compatibility issue before in "Do you need a reference implementation for formats?" post and now I’d like to introduce Transhipment library that aims to resolve this issue.

Transhipment provides implementation for the most popular formats that make sense in the context of data sharing. Supported schemas:

  • Article
  • Book
  • ContactPoint
  • CreativeWork
  • Event
  • GeoCoordinate
  • LocalBusiness
  • Movie
  • MusicAlbum
  • MusicGroup
  • MusicPlaylist
  • MusicRecording
  • Organization
  • Person
  • Place
  • PostalAddress
  • Product
  • Recipe

In addition, the library includes a few helpers to simplify use of these schemas with Share Contract:

  • SchemaFactory class creates data schema objects
  • Schema class provides identifiers for the supported schemas
  • SetStructuredData and GetStructuredDataAsync extension methods for DataPackage

Below you can see a complete example of using Transhipment for sharing geo coordinates from C# app:

void DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
    var request = args.Request;

    var geo = SchemaFactory.Create(Schema.GeoCoordinates) as IGeoCoordinates;
    geo.Name = "Polar Bear Provincial Park";
    geo.Latitude = "54.596931";
    geo.Longitude = "-83.283978";

    request.Data.Properties.Title = "Sample data";
    request.Data.Properties.Description = "data for " + geo.Type;

Transhipment is a WinRT library and can be used from all supported languages, e.g. from JavaScript:

function dataRequested(e) {
    var request = e.request;

    var geo = Transhipment.SchemaFactory.create(Transhipment.Schema.geoCoordinates); = "Polar Bear Provincial Park";
    geo.latitude = "54.596931";
    geo.longitude = "-83.283978"; = "Sample data"; = "data for " + geo.type;

    Transhipment.SchemaFactory.setStructuredData(, geo);

Retrieving of shared data in target app is also easy:

public async void Activate(ShareTargetActivatedEventArgs args)
    var shareOperation = args.ShareOperation;
    var geo = await shareOperation.Data.GetStructuredDataAsync(Schema.GeoCoordinates) as IGeoCoordinates;
    if (geo != null)
        DefaultViewModel["ThingName"] = geo.Name;
        DefaultViewModel["Latitude"] = geo.Latitude;
        DefaultViewModel["Longitude"] = geo.Longitude;

    // ...


All Transhipment schemas support ExtendedProperties dictionary to extend formats and share application-specific data.

How to start

Transhipment is available as a NuGet package.

PM> Install-Package Transhipment

Transhipment source code is on GitHub and if you miss any of formats – feel free to send me your pull requests.

blog comments powered by Disqus