Esempio n. 1
0
        private void VariantWrapper()
        {
            long toWrap   = (long)rand.Next();
            var  val      = new VariantWrapper(toWrap);
            long expected = toWrap * 2;

            // Get and set property
            obj.Variant_Property = val;
            Assert.AreEqual(val.WrappedObject, obj.Variant_Property);

            // Call method with return value
            dynamic ret = obj.Variant_Ret(val);

            Assert.AreEqual(expected, ret);

            // Call method passing by ref
            obj.Variant_InOut(ref val);
            Assert.AreEqual(expected, val.WrappedObject);
        }
Esempio n. 2
0
        public Variant(VariantWrapper wrapper)
        {
            if (wrapper == null)
            {
                throw new ArgumentNullException("wrapper");
            }

            varType   = (ushort)(VarEnum.VT_VARIANT | VarEnum.VT_BYREF);
            reserved1 = 0;
            reserved2 = 0;
            reserved3 = 0;
            boolvalue = 0;
            ptr1      = IntPtr.Zero;
            ptr2      = IntPtr.Zero;

            // Allocate memory for the VT_BYREF VT_VARIANT.
            ptr1 = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Variant)));

            // Move the wrapped object into the memory.
            Marshal.GetNativeVariantForObject(wrapper.WrappedObject, ptr1);
        }
Esempio n. 3
0
        public void Ctor_Value(object value)
        {
            var wrapper = new VariantWrapper(value);

            Assert.Equal(value, wrapper.WrappedObject);
        }
Esempio n. 4
0
 public int OnScriptTerminate(VariantWrapper varResult, ref System.Runtime.InteropServices.ComTypes.EXCEPINFO excepInfo)
 {
     return(0);
 }