Example #1
0
        public void BinaryProp()
        {
            CheckDisposed();
            using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative(10, typeof(int)))
            {
                int chvo = 99;
                m_ISilDataAccess.BinaryPropRgb(1112, 2221, arrayPtr, 10, out chvo);
                Assert.AreEqual(0, chvo);
                Assert.IsFalse(m_ISilDataAccess.IsDirty());

                byte[] prgb = new byte[] { 3, 4, 5 };
                m_ISilDataAccess.SetBinary(1112, 2221, prgb, prgb.Length);
                m_ISilDataAccess.BinaryPropRgb(1112, 2221, ArrayPtr.Null, 0, out chvo);
                Assert.AreEqual(prgb.Length, chvo);

                m_ISilDataAccess.BinaryPropRgb(1112, 2221, arrayPtr, 10, out chvo);
                byte[] prgbNew = (byte[])MarshalEx.NativeToArray(arrayPtr, chvo, typeof(byte));
                Assert.AreEqual(prgb.Length, prgbNew.Length);
                for (int i = 0; i < prgbNew.Length; i++)
                {
                    Assert.AreEqual(prgb[i], prgbNew[i]);
                }
                Assert.IsTrue(m_ISilDataAccess.IsDirty());

                byte[] prgb2 = new byte[] { 6, 7, 8, 9 };
                m_ISilDataAccess.SetBinary(1112, 2221, prgb2, prgb2.Length);
                m_ISilDataAccess.BinaryPropRgb(1112, 2221, arrayPtr, 10, out chvo);
                prgbNew = (byte[])MarshalEx.NativeToArray(arrayPtr, chvo, typeof(byte));
                Assert.AreEqual(prgb2.Length, prgbNew.Length);
                for (int i = 0; i < prgbNew.Length; i++)
                {
                    Assert.AreEqual(prgb2[i], prgbNew[i]);
                }
                Assert.IsTrue(m_ISilDataAccess.IsDirty());

                Exception ex = null;
                try
                {
                    m_ISilDataAccess.BinaryPropRgb(1112, 2221, arrayPtr, 2, out chvo);
                }
                catch (Exception e)
                {
                    ex = e;
                }
                Assert.AreEqual(typeof(System.Runtime.InteropServices.COMException),
                                ex.GetType());
                Assert.IsTrue(m_ISilDataAccess.IsDirty());

                CheckProp(1112, 2221, prgb2, CellarModuleDefns.kcptBinary);
            }
        }
Example #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Copies a "binary" Flid as actual binary bytes.
        /// </summary>
        /// <param name="thisFlid">The this flid.</param>
        /// <param name="hvoSrc">The hvo SRC.</param>
        /// <param name="hvoNew">The hvo new.</param>
        /// ------------------------------------------------------------------------------------
        private void CopyBinaryAsBinary(int thisFlid, int hvoSrc, int hvoNew)
        {
            byte[] bdata;
            var    cbytes = ((ISilDataAccessManaged)m_sda).get_Binary(hvoSrc, thisFlid, out bdata);

            m_sda.SetBinary(hvoNew, thisFlid, bdata, cbytes);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="hvo"></param>
 /// <param name="tag"></param>
 /// <param name="_rgb"></param>
 /// <param name="cb"></param>
 public void SetBinary(int hvo, int tag, byte[] _rgb, int cb)
 {
     VerifyUpdate(hvo, tag);
     m_sda.SetBinary(hvo, tag, _rgb, cb);
 }
Example #4
0
 /// <summary>
 /// Change a binary data property of an object.
 /// The caller should also call PropChanged to notify interested parties,
 /// except where the change is being made to a newly created object.
 ///</summary>
 /// <param name='hvo'> </param>
 /// <param name='tag'> </param>
 /// <param name='_rgb'> </param>
 /// <param name='cb'> </param>
 public virtual void SetBinary(int hvo, int tag, byte[] _rgb, int cb)
 {
     m_baseSda.SetBinary(hvo, tag, _rgb, cb);
 }