แชร์ผ่าน


COMVariant.container Method

Definition

Overloads

container()

Gets or sets the value of a COMVariant object of the container data type.

container(Object[])
container(Object[], COMVariantType)

container()

Gets or sets the value of a COMVariant object of the container data type.

public:
 virtual cli::array <System::Object ^> ^ container();
public virtual object[] container ();
abstract member container : unit -> obj[]
override this.container : unit -> obj[]
Public Overridable Function container () As Object()

Returns

Object[]

The current container.

Remarks

The possible values for the newType parameter are a subset of the values that are supplied by the COMVariantType system enum:

  • VT_I2
  • VT_I4
  • VT_R4
  • VT_R8
  • VT_CY
  • VT_DATE
  • VT_BSTR
  • VT_ERROR
  • VT_BOOL
  • VT_DECIMAL
  • VT_I1
  • VT_UI1
  • VT_UI2
  • VT_UI4
  • VT_I8
  • VT_UI8
  • VT_INT
  • VT_UINT

If you pass in a value that has a different data type than the object, the data type of the object will be changed to match the data type of the value. When a container is stored in a COMVariant object, the binary representation of the container is stored in a binary array (see the COMVariant.safeArray method). The container property is useful when you need to store data in a database COM object and then later read the data back into Finance and Operations without the COM object processing the data. The container property is an advanced property of the COMVariant class. It should be used with caution because the content of the binary array that the container is stored in, inside the COMVariant object, must not be changed by any COM object.

The following example creates a new COMVariant object of type container. The data in the container is passed to, and used by, a database COM object. Note The code in the following section contains a hypothetical COM object MyDatabaseCOM.Object" and will therefore not run in Finance and Operations, unless such an object is created outside Finance and Operations.

{ 
    COM com; 
    COMVariant var = new COMVariant(); 
    container con; 
    InteropPermission perm; 
    // Set code access permission to help protect use of COM object 
    perm = new InteropPermission(InteropKind::ComInterop); 
    if (perm == null) 
    { 
        return; 
    } 
    // Permission scope starts here 
    perm.assert(); 
    // Put some data in the container 
    con = conins(con, 1, "Element 1"); 
    con = conins(con, 2, "Element 2"); 
    // Set value of the object and ensure the data 
    // is stored in a binary array of bytes 
    var.container(con, COMVariantType::VT_UI1); 
    // Create a database object to store the data in 
    com = new COM("MyDatabaseCOM.Object"); 
    com.writeData(var); 
    // ... 
    // Close code access permission 
    CodeAccessPermission::revertAssert(); 
}

Applies to

container(Object[])

public:
 virtual cli::array <System::Object ^> ^ container(cli::array <System::Object ^> ^ objArray1);
public virtual object[] container (object[] objArray1);
abstract member container : obj[] -> obj[]
override this.container : obj[] -> obj[]
Public Overridable Function container (objArray1 As Object()) As Object()

Parameters

objArray1
Object[]

Returns

Object[]

Applies to

container(Object[], COMVariantType)

public:
 virtual cli::array <System::Object ^> ^ container(cli::array <System::Object ^> ^ _newValue, Dynamics::AX::Application::COMVariantType _newType);
public virtual object[] container (object[] _newValue, Dynamics.AX.Application.COMVariantType _newType);
abstract member container : obj[] * Dynamics.AX.Application.COMVariantType -> obj[]
override this.container : obj[] * Dynamics.AX.Application.COMVariantType -> obj[]
Public Overridable Function container (_newValue As Object(), _newType As COMVariantType) As Object()

Parameters

_newValue
Object[]

The type of the new container; optional. The default is for the container to store integers.

_newType
COMVariantType

The type of the new container; optional. The default is for the container to store integers.

Returns

Object[]

Applies to