Пример #1
0
        // constructs a ByRef variant to pass contents of another variant ByRef.
        public void SetAsByrefVariantIndirect(ref Variant value)
        {
            Debug.Assert(IsEmpty); // The setter can only be called once as VariantClear might be needed otherwise
            Debug.Assert((value.VariantType & VarEnum.VT_BYREF) == 0, "double indirection");

            switch (value.VariantType)
            {
            case VarEnum.VT_EMPTY:
            case VarEnum.VT_NULL:
                // these cannot combine with VT_BYREF. Should try passing as a variant reference
                SetAsByrefVariant(ref value);
                return;

            case VarEnum.VT_RECORD:
                // VT_RECORD's are weird in that regardless of is the VT_BYREF flag is set or not
                // they have the same internal representation.
                _typeUnion._unionTypes._record = value._typeUnion._unionTypes._record;
                break;

            case VarEnum.VT_DECIMAL:
                _typeUnion._unionTypes._byref = UnsafeMethods.ConvertDecimalByrefToPtr(ref value._decimal);
                break;

            default:
                _typeUnion._unionTypes._byref = UnsafeMethods.ConvertIntPtrByrefToPtr(ref value._typeUnion._unionTypes._byref);
                break;
            }
            VariantType = (value.VariantType | VarEnum.VT_BYREF);
        }
Пример #2
0
 public void SetAsByrefDispatch(ref IntPtr value)
 {
     Debug.Assert(IsEmpty); // The setter can only be called once as VariantClear might be needed otherwise
     VariantType = (VarEnum.VT_DISPATCH | VarEnum.VT_BYREF);
     _typeUnion._unionTypes._byref = UnsafeMethods.ConvertIntPtrByrefToPtr(ref value);
 }