Поделиться через


JavaPeerableExtensions.TryJavaCast<TResult> Method

Definition

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

public static bool TryJavaCast<TResult>(this Java.Interop.IJavaPeerable? self, out TResult? result) where TResult : class, Java.Interop.IJavaPeerable;
static member TryJavaCast : Java.Interop.IJavaPeerable * 'Result -> bool (requires 'Result : null and 'Result :> Java.Interop.IJavaPeerable)

Type Parameters

TResult

The type to coerce self to.

Parameters

self
IJavaPeerable

A IJavaPeerable instance to coerce to type TResult.

result
TResult

When this method returns, contains a value of type TResult if self can be coerced to the Java type corresponding to TResult, or null if the coercion is not valid.

Returns

true if <pramref name="self"></pramref> was converted successfully; otherwise, false.

Exceptions

The Java peer type for TResult could not be found.

The type TResult or a Invoker type for TResult does not provide an activation constructor, a constructor with a singature of (ref JniObjectReference, JniObjectReferenceOptions) or (IntPtr, JniHandleOwnership).

Remarks

<block subset="none" type="note"> Implementations of IJavaPeerable consist of two halves: a Java peer and a managed peer. The PeerReference property associates the managed peer to the Java peer. </block> <block subset="none" type="note"> The JniTypeSignatureAttribute or RegisterAttribute custom attributes are used to associated a managed type to a Java type. </block>

Applies to

See also