示例#1
0
 /// <summary>
 /// When managed code calls unmanaged methods or exposes managed fields to unmanaged code, it is sometimes necessary to provide specific information about how the
 /// managed types should be marshalled to and from the unmanaged types.
 /// </summary>
 /// <param name="unmanagedType">
 /// The unmanaged type to which the managed type will be marshalled. This can be be UnmanagedType.CustomMarshaler, in which case the umanaged type
 /// is decided at runtime.
 /// </param>
 /// The unmanged element type of the unmanaged array.
 /// <param name="elementType">
 /// </param>
 /// <param name="elementSize">
 /// The size of an element of the fixed sized umanaged array.
 /// </param>
 /// <param name="elementSizeMultiplier">
 /// A multiplier that must be applied to the value of the parameter specified by ParamIndex in order to work out the total size of the unmanaged array.
 /// </param>
 /// <param name="iidParameterIndex">Specifies the index of the parameter that contains the value of the Inteface Identifier (IID) of the marshalled object.</param>
 /// <param name="numberOfElements">
 /// The number of elements in the fixed size portion of the unmanaged array.
 /// </param>
 /// <param name="paramIndex">
 /// The zero based index of the parameter in the unmanaged method that contains the number of elements in the variable portion of unmanaged array.
 /// If the index is null, the variable portion is of size zero, or the caller conveys the size of the variable portion of the array to the unmanaged method in some other way.
 /// </param>
 /// <param name="safeArrayElementSubtype">
 /// The type to which the variant values of all elements of the safe array must belong. See also SafeArrayElementUserDefinedSubType.
 /// (The element type of a safe array is VARIANT. The "sub type" specifies the value of all of the tag fields (vt) of the element values. )
 /// </param>
 /// <param name="safeArrayElementUserDefinedSubtype">
 /// A reference to the user defined type to which the variant values of all elements of the safe array must belong.
 /// (The element type of a safe array is VARIANT. The tag fields will all be either VT_DISPATCH or VT_UNKNOWN or VT_RECORD.
 /// The "user defined sub type" specifies the type of value the ppdispVal/ppunkVal/pvRecord fields of the element values may point to.)
 /// May be null if the above does not apply.
 /// </param>
 /// <param name="customMarshaller">
 /// A reference to the type implementing the custom marshaller. Must not be be null if unmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler.
 /// </param>
 /// <param name="customMarshallerRuntimeArgument">
 /// An argument string (cookie) passed to the custom marshaller at run time. Must not be be null if unmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler.
 /// </param>
 public MarshallingInformation(System.Runtime.InteropServices.UnmanagedType unmanagedType,
                               System.Runtime.InteropServices.UnmanagedType elementType, uint elementSize, uint elementSizeMultiplier, uint iidParameterIndex, uint numberOfElements, uint?paramIndex,
                               System.Runtime.InteropServices.VarEnum safeArrayElementSubtype, ITypeReference /*?*/ safeArrayElementUserDefinedSubtype,
                               ITypeReference /*?*/ customMarshaller, string /*?*/ customMarshallerRuntimeArgument)
 //^ requires unmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler ==>
 //^   customMarshaller != null && customMarshallerRuntimeArgument != null;
 //^ requires iidParameterIndex > 0 ==> unmanagedType == System.Runtime.InteropServices.UnmanagedType.Interface;
 //^ requires unmanagedType == System.Runtime.InteropServices.UnmanagedType.SafeArray &&
 //^  (safeArrayElementSubType == System.Runtime.InteropServices.VarEnum.VT_DISPATCH ||
 //^   safeArrayElementSubType == System.Runtime.InteropServices.VarEnum.VT_UNKNOWN ||
 //^   safeArrayElementSubType == System.Runtime.InteropServices.VarEnum.VT_RECORD) ==>
 //^      safeArrayElementUserDefinedSubType != null;
 {
     this.customMarshaller = customMarshaller;
     this.customMarshallerRuntimeArgument = customMarshallerRuntimeArgument;
     this.elementSize                        = elementSize;
     this.elementSizeMultiplier              = elementSizeMultiplier;
     this.elementType                        = elementType;
     this.iidParameterIndex                  = iidParameterIndex;
     this.numberOfElements                   = numberOfElements;
     this.paramIndex                         = paramIndex;
     this.safeArrayElementSubtype            = safeArrayElementSubtype;
     this.safeArrayElementUserDefinedSubtype = safeArrayElementUserDefinedSubtype;
     this.unmanagedType                      = unmanagedType;
 }
示例#2
0
 //^ requires unmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler ==>
 //^   customMarshaller != null && customMarshallerRuntimeArgument != null;
 //^ requires iidParameterIndex > 0 ==> unmanagedType == System.Runtime.InteropServices.UnmanagedType.Interface;
 //^ requires unmanagedType == System.Runtime.InteropServices.UnmanagedType.SafeArray &&
 //^  (safeArrayElementSubType == System.Runtime.InteropServices.VarEnum.VT_DISPATCH ||
 //^   safeArrayElementSubType == System.Runtime.InteropServices.VarEnum.VT_UNKNOWN ||
 //^   safeArrayElementSubType == System.Runtime.InteropServices.VarEnum.VT_RECORD) ==>
 //^      safeArrayElementUserDefinedSubType != null;
 /// <summary>
 /// When managed code calls unmanaged methods or exposes managed fields to unmanaged code, it is sometimes necessary to provide specific information about how the 
 /// managed types should be marshalled to and from the unmanaged types.
 /// </summary>
 /// <param name="unmanagedType">
 /// The unmanaged type to which the managed type will be marshalled. This can be be UnmanagedType.CustomMarshaler, in which case the umanaged type
 /// is decided at runtime.
 /// </param>
 /// The unmanged element type of the unmanaged array.
 /// <param name="elementType">
 /// </param>
 /// <param name="elementSize">
 /// The size of an element of the fixed sized umanaged array.
 /// </param>
 /// <param name="elementSizeMultiplier">
 /// A multiplier that must be applied to the value of the parameter specified by ParamIndex in order to work out the total size of the unmanaged array.
 /// </param>
 /// <param name="iidParameterIndex">Specifies the index of the parameter that contains the value of the Inteface Identifier (IID) of the marshalled object.</param>
 /// <param name="numberOfElements">
 /// The number of elements in the fixed size portion of the unmanaged array.
 /// </param>
 /// <param name="paramIndex">
 /// The zero based index of the parameter in the unmanaged method that contains the number of elements in the variable portion of unmanaged array.
 /// If the index is null, the variable portion is of size zero, or the caller conveys the size of the variable portion of the array to the unmanaged method in some other way.
 /// </param>
 /// <param name="safeArrayElementSubtype">
 /// The type to which the variant values of all elements of the safe array must belong. See also SafeArrayElementUserDefinedSubType.
 /// (The element type of a safe array is VARIANT. The "sub type" specifies the value of all of the tag fields (vt) of the element values. )
 /// </param>
 /// <param name="safeArrayElementUserDefinedSubtype">
 /// A reference to the user defined type to which the variant values of all elements of the safe array must belong.
 /// (The element type of a safe array is VARIANT. The tag fields will all be either VT_DISPATCH or VT_UNKNOWN or VT_RECORD.
 /// The "user defined sub type" specifies the type of value the ppdispVal/ppunkVal/pvRecord fields of the element values may point to.)
 /// May be null if the above does not apply.
 /// </param>
 /// <param name="customMarshaller">
 /// A reference to the type implementing the custom marshaller. Must not be be null if unmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler.
 /// </param>
 /// <param name="customMarshallerRuntimeArgument">
 /// An argument string (cookie) passed to the custom marshaller at run time. Must not be be null if unmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler.
 /// </param>
 public MarshallingInformation(System.Runtime.InteropServices.UnmanagedType unmanagedType,
     System.Runtime.InteropServices.UnmanagedType elementType, uint elementSize, uint elementSizeMultiplier, uint iidParameterIndex, uint numberOfElements, uint? paramIndex,
     System.Runtime.InteropServices.VarEnum safeArrayElementSubtype, ITypeReference/*?*/ safeArrayElementUserDefinedSubtype,
     ITypeReference/*?*/ customMarshaller, string/*?*/ customMarshallerRuntimeArgument)
 {
     this.customMarshaller = customMarshaller;
       this.customMarshallerRuntimeArgument = customMarshallerRuntimeArgument;
       this.elementSize = elementSize;
       this.elementSizeMultiplier = elementSizeMultiplier;
       this.elementType = elementType;
       this.iidParameterIndex = iidParameterIndex;
       this.numberOfElements = numberOfElements;
       this.paramIndex = paramIndex;
       this.safeArrayElementSubtype = safeArrayElementSubtype;
       this.safeArrayElementUserDefinedSubtype = safeArrayElementUserDefinedSubtype;
       this.unmanagedType = unmanagedType;
 }