: worldwind.net code (v3)

Coding With the .NET v3 Proxy Types Tutorial

The purpose of this tutorial is to introduce you to the basics of writing .NET applications that use .NET v3 Proxy Types.

The v3 moniker stems from Codemesh's C++ and .NET runtime libraries that have to be compatible with the proxy types because the proxy types delegate most of their work to that runtime library. The runtime library is currently at major version 3, hence the v3 label.

We strive to make the .NET proxy types as faithful to their underlying Java types as possible, but that does not mean that there aren't any pitfalls. Some surprises are simply unavoidable. For example, there is simply no way you will ever be able in .NET to use the .class suffix to refer to a type; class is a reserved name and cannot be used like that. So how do you write .NET code that uses a Java type instance?

This tutorial will hopefully answer this and all similar questions that you might run into while using the .NET v3 proxy types.

 

Prerequisites

The focus of this tutorial is to introduce you to writing code with proxy types, not necessarily to teach you how to configure the application so it will actually run. We will have a lesson on how to configure your .NET project and as one of the tests we'll try to run the application you built but another tutorial deals with the application's runtime configuration in much more detail.

You should have access to a properly set up C# compiler if you are going to try to follow the step-by-step instructions but you can also just read the lessons, in which case a C# compiler is not necessary.

 

Lesson Plan

Project Setup

Learn what you need to do to use proxy types in your .NET projects.

Constructing Proxy Objects

Learn how to instantiate a Java object through its proxy type.

The Proxy Object Lifecycle

Learn what happens when a proxy object becomes eligible for garbage collection.

Interfaces

Learn how to access static interface members through Impl types.

Using Strings

Learn how to use strings in connection with proxy types.

Dealing With null

Learn how to check whether a return value is null or not.

Accessing Fields

Learn how to access fields in your proxy types.

Calling Methods

Learn how to call methods on your proxy types.

Using Array Proxy Types

Learn how to create arrays and access their elements.

Casting Between Proxy Types

Learn how to cast a proxy object to a different proxy type. This lesson discusses the From() function.

Handling Exceptions

Learn how to handle exceptions thrown on the Java side.

Multi-threaded Execution

Learn how to write proper multi-threaded code that avoids race conditions.