SoNetBaseGetInstance Method (IntPtr, Type) |
Gets a managed object for the given native handle (non generic version).
Namespace: OIV.InventorAssembly: OIV.Inventor.Base (in OIV.Inventor.Base.dll) Version: 2024.2.2.0 (10.16.2.0)
Syntax public static SoNetBase GetInstance(
IntPtr handle,
Type managedType
)
Public Shared Function GetInstance (
handle As IntPtr,
managedType As Type
) As SoNetBase
public:
static SoNetBase^ GetInstance(
IntPtr handle,
Type^ managedType
)
static member GetInstance :
handle : IntPtr *
managedType : Type -> SoNetBase
Parameters
- handle
- Type: SystemIntPtr
the native handle. - managedType
- Type: SystemType
the type of the managed object created.
Return Value
Type:
SoNetBase
A managed wrapped object of the native object defined by the handle or
null if the handle is zero.
Exceptions Exception | Condition |
---|
ArgumentException |
Thrown when the managedType does not represent a closed constructed type (i.e.
the managed type is a generic type definition, it does not represent
a fully qualified type).
- or -
When the managedType represents an abstract type.
|
Remarks
Gets a managed object for the given native handle (non generic version).
Note that this method does not check if the native type
of the object (defined by the handle)
is compliant with the managed type given by the
managedType. You must be sure
that the handle can be wrapped as
a managedType.
Examples
The following example demonstrates the use of this method in a c++/cli context.
// Considering a native pointer on a SoTypedObject from
// which you want to create a managed object.
::SoTypedObject* soObject = ...;
// Construct a managed string of the native type name.
System::String^ nativeTypeName = gcnew System::String(soObject->getTypeId().getName().getString());
// Retrieve the associated managed type.
System::Type^ managedType = OIV::Inventor::SoNetBase::GetRegisteredType( nativeTypeName );
// Create the wrapper object if the type is known.
if ( managedType != nullptr )
// The managed object can be downcasted to an object of type managedType or
// to any base type of managedType.
OIV::Inventor::SoNetBase^ managedObject = OIV::Inventor::SoNetBase::GetInstance( (System::IntPtr) soObject, managedType );
See Also