API Helper Libraries - .NET
For general .NET usage, we've made a .NET class library that abstracts away the low-level logic of making HTTP requests to the API and instead exposes higher-level classes and methods.
This library provides the same asynchronous support as the Silverlight library, but also offers synchronous methods for convenience. The synchronous methods may be better suited for server-side scenarios.
You can download this library along with our other helper libraries on
our libraries page. To use it, include
the .NET ZoomitWebApi.dll assembly and
add a reference to the
Microsoft.Zoomit namespace.
Class outline
public class DziInfo
{
public Uri Uri { get; }
public int Width { get; }
public int Height { get; }
public int TileSize { get; }
public int TileOverlap { get; }
public string TileFormat { get; }
}
public class ContentInfo
{
public string Id { get; }
public Uri Uri { get; }
public bool Ready { get; }
public bool Failed { get; }
public double Progress { get; }
public Uri ViewUri { get; }
public string EmbedHtml { get; }
public string Title { get; }
public string AttributionText { get; }
public Uri AttributionUri { get; }
public DziInfo Dzi { get; }
}
public static class Zoomit
{
// asynchronous:
public static IAsyncResult BeginGetContentInfo(
string id, AsyncCallback callback, object state);
public static IAsyncResult BeginGetContentInfo(
Uri uri, AsyncCallback callback, object state);
public static ContentInfo EndGetContentInfo(
IAsyncResult asyncResult);
public static bool TryEndGetContentInfo(
IAsyncResult asyncResult, out ContentInfo content);
// synchronous:
public static ContentInfo GetContentInfo(string id);
public static ContentInfo GetContentInfo(Uri uri);
public static bool TryGetContentInfo(
string id, out ContentInfo contentInfo);
public static bool TryGetContentInfo(
Uri uri, out ContentInfo contentInfo);
}
Usage example
A simple usage example is below, but we recommend reading the Silverlight quickstart for more helpful guidance.
try
{
ContentInfo content =
Zoomit.GetContentInfo(new Uri("http://example.com/"));
// do something with content
}
catch (Exception e)
{
// do something with exception
}
