Click or drag to resize
SoNetBaseGetInstance Method (IntPtr, Type)
Gets a managed object for the given native handle (non generic version).

Namespace: OIV.Inventor
Assembly: OIV.Inventor.Base (in OIV.Inventor.Base.dll) Version: 2023.1.3.0 (2023.1.3)
Syntax
public static SoNetBase GetInstance(
	IntPtr handle,
	Type managedType
)

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
ExceptionCondition
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