Exemple #1
0
        public unsafe void Clear()
        {
            VarEnum variantType = this.VariantType;

            if ((variantType & VarEnum.VT_BYREF) != VarEnum.VT_EMPTY)
            {
                this.VariantType = VarEnum.VT_EMPTY;
            }
            else if ((variantType & VarEnum.VT_ARRAY) != VarEnum.VT_EMPTY || variantType == VarEnum.VT_BSTR || (variantType == VarEnum.VT_UNKNOWN || variantType == VarEnum.VT_DISPATCH) || (variantType == VarEnum.VT_VARIANT || variantType == VarEnum.VT_RECORD || variantType == VarEnum.VT_VARIANT))
            {
                fixed(Variant *variantPtr = &this)
                NativeMethods.VariantClear((IntPtr)((void *)variantPtr));
            }
            else
            {
                this.VariantType = VarEnum.VT_EMPTY;
            }
        }
        // Token: 0x0600621B RID: 25115 RVA: 0x0014DDA4 File Offset: 0x0014BFA4
        public unsafe void Clear()
        {
            VarEnum variantType = this.VariantType;

            if ((variantType & VarEnum.VT_BYREF) != VarEnum.VT_EMPTY)
            {
                this.VariantType = VarEnum.VT_EMPTY;
                return;
            }
            if ((variantType & VarEnum.VT_ARRAY) != VarEnum.VT_EMPTY || variantType == VarEnum.VT_BSTR || variantType == VarEnum.VT_UNKNOWN || variantType == VarEnum.VT_DISPATCH || variantType == VarEnum.VT_VARIANT || variantType == VarEnum.VT_RECORD || variantType == VarEnum.VT_VARIANT)
            {
                fixed(IntPtr *ptr = (IntPtr *)(&this))
                {
                    NativeMethods.VariantClear((IntPtr)((void *)ptr));
                }

                return;
            }
            this.VariantType = VarEnum.VT_EMPTY;
        }
Exemple #3
0
        public unsafe void Clear()
        {
            VarEnum variantType = this.VariantType;

            if ((variantType & VarEnum.VT_BYREF) != VarEnum.VT_EMPTY)
            {
                this.VariantType = VarEnum.VT_EMPTY;
            }
            else if (((((variantType & VarEnum.VT_ARRAY) != VarEnum.VT_EMPTY) || (variantType == VarEnum.VT_BSTR)) || ((variantType == VarEnum.VT_UNKNOWN) || (variantType == VarEnum.VT_DISPATCH))) || ((variantType == VarEnum.VT_VARIANT) || (variantType == VarEnum.VT_RECORD)))
            {
                fixed(IntPtr *ptrRef = ((IntPtr *)this))
                {
                    NativeMethods.VariantClear((IntPtr)ptrRef);
                }
            }
            else
            {
                this.VariantType = VarEnum.VT_EMPTY;
            }
        }
Exemple #4
0
        /// <summary>
        /// Release any unmanaged memory associated with the Variant
        /// </summary>
        /// <returns></returns>
        public void Clear()
        {
            // We do not need to call OLE32's VariantClear for primitive types or ByRefs
            // to safe ourselves the cost of interop transition.
            // ByRef indicates the memory is not owned by the VARIANT itself while
            // primitive types do not have any resources to free up.
            // Hence, only safearrays, BSTRs, interfaces and user types are
            // handled differently.
            VarEnum vt = VariantType;

            if ((vt & VarEnum.VT_BYREF) != 0)
            {
                VariantType = VarEnum.VT_EMPTY;
            }
            else if (
                ((vt & VarEnum.VT_ARRAY) != 0) ||
                ((vt) == VarEnum.VT_BSTR) ||
                ((vt) == VarEnum.VT_UNKNOWN) ||
                ((vt) == VarEnum.VT_DISPATCH) ||
                ((vt) == VarEnum.VT_VARIANT) ||
                ((vt) == VarEnum.VT_RECORD) ||
                ((vt) == VarEnum.VT_VARIANT)
                )
            {
                unsafe
                {
                    fixed(void *pThis = &this)
                    {
                        NativeMethods.VariantClear((IntPtr)pThis);
                    }
                }
                BCLDebug.Assert(IsEmpty, "variant");
            }
            else
            {
                VariantType = VarEnum.VT_EMPTY;
            }
        }