public void BinaryPropTest()
        {
            CheckDisposed();

            // ScrImportSet::ImportSettings:Binary
            // Set class first, or it will throw an exception.
            int  hvo      = 1;
            uint clidAnal = SilDataAccess.MetaDataCache.GetClassId("ScrImportSet");

            SilDataAccess.SetInt(hvo, (int)CmObjectFields.kflidCmObject_Class, (int)clidAnal);
            int tag = (int)SilDataAccess.MetaDataCache.GetFieldId("ScrImportSet", "ImportSettings", false);

            using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative(3, typeof(int)))
            {
                int    chvo;
                byte[] prgb = new byte[] { 3, 4, 5 };
                SilDataAccess.SetBinary(hvo, tag, prgb, prgb.Length);
                SilDataAccess.BinaryPropRgb(hvo, tag, arrayPtr, 3, 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]);
                }
            }
        }
Beispiel #2
0
        public void BinaryPropKNTTest()
        {
            const int hvo = 1;
            // Set class first, or it will throw the exception in the wrong place.
            var clid = SilDataAccess.MetaDataCache.GetClassId("ClassI");

            SilDataAccess.SetInt(hvo, (int)CmObjectFields.kflidCmObject_Class, clid);
            var tag = SilDataAccess.MetaDataCache.GetFieldId("ClassI", "BinaryProp9", false);
            int chvo;

            SilDataAccess.BinaryPropRgb(hvo, tag, ArrayPtr.Null, 0, out chvo);
        }
Beispiel #3
0
        public void BinaryPropWrongLengthTest()
        {
            const int hvo  = 1;
            var       clid = SilDataAccess.MetaDataCache.GetClassId("ClassI");

            SilDataAccess.SetInt(hvo, (int)CmObjectFields.kflidCmObject_Class, clid);
            var tag = SilDataAccess.MetaDataCache.GetFieldId("ClassI", "BinaryProp9", false);

            using (var arrayPtr = MarshalEx.ArrayToNative <int>(2))
            {
                var prgb = new byte[] { 3, 4, 5 };
                int chvo;
                SilDataAccess.SetBinary(hvo, tag, prgb, prgb.Length);
                SilDataAccess.BinaryPropRgb(hvo, tag, arrayPtr, 2, out chvo);
            }
        }
        public void BinaryPropWrongLengthTest()
        {
            CheckDisposed();

            int  hvo  = 1;
            uint clid = SilDataAccess.MetaDataCache.GetClassId("ScrImportSet");

            SilDataAccess.SetInt(hvo, (int)CmObjectFields.kflidCmObject_Class, (int)clid);
            int tag = (int)SilDataAccess.MetaDataCache.GetFieldId("ScrImportSet", "ImportSettings", false);

            using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative(2, typeof(int)))
            {
                byte[] prgb = new byte[] { 3, 4, 5 };
                int    chvo;
                SilDataAccess.SetBinary(hvo, tag, prgb, prgb.Length);
                SilDataAccess.BinaryPropRgb(hvo, tag, arrayPtr, 2, out chvo);
            }
        }
        public void BinaryPropKNTTest()
        {
            CheckDisposed();

            int hvo = 1;
            // Set class first, or it will throw the exception in the wrong place.
            uint clid = SilDataAccess.MetaDataCache.GetClassId("ScrImportSet");

            SilDataAccess.SetInt(hvo, (int)CmObjectFields.kflidCmObject_Class, (int)clid);
            int tag = (int)SilDataAccess.MetaDataCache.GetFieldId("ScrImportSet", "ImportSettings", false);
            //using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative(2, typeof(int)))
            //{
            int chvo;

            SilDataAccess.BinaryPropRgb(hvo, tag, ArrayPtr.Null, 0, 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]);
            //}
        }
Beispiel #6
0
        public void BinaryPropTest()
        {
            // ClassH::BinaryProp8:Binary
            // Set class first, or it will throw an exception.
            const int hvo      = 1;
            var       clidAnal = SilDataAccess.MetaDataCache.GetClassId("ClassH");

            SilDataAccess.SetInt(hvo, (int)CmObjectFields.kflidCmObject_Class, clidAnal);
            var tag = SilDataAccess.MetaDataCache.GetFieldId("ClassH", "BinaryProp8", false);

            using (var arrayPtr = MarshalEx.ArrayToNative <int>(3))
            {
                int chvo;
                var prgb = new byte[] { 3, 4, 5 };
                SilDataAccess.SetBinary(hvo, tag, prgb, prgb.Length);
                SilDataAccess.BinaryPropRgb(hvo, tag, arrayPtr, 3, out chvo);
                var prgbNew = MarshalEx.NativeToArray <byte>(arrayPtr, chvo);
                Assert.AreEqual(prgb.Length, prgbNew.Length);
                for (var i = 0; i < prgbNew.Length; i++)
                {
                    Assert.AreEqual(prgb[i], prgbNew[i]);
                }
            }
        }